You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could almost see a "number" format being useful, to specify strings that contain numeric data, but there's so many ways of representing a number, and some of them might not be suitable for a particular application. Also some numeric representations aren't practical in some languages.
For example, one could start out defining a number format as "any string that can be converted to a number in my language" -- so for perl, the easy way of implementing that is with looks_like_number, which handles values like "2.0", "2.5", "2e-3", "Inf" and "NaN" - but doesn't handle "0xDEADBEEF" or "0x1.23p-4" or "0 but true" (which are all treated internally as numbers without warning). Or in C, one could use atoi() but that doesn't match many numeric forms cleanly either.
tldr: formats like this are best defined locally to an application using a definition, so it can be tailored to the exact needs of that application, framework and language.
Activity
darrelmiller commentedon Feb 24, 2017
The semantics of
decimalcan be added using theformatproperty. It will be included in theformatregistry that we will be creating #845spacether commentedon Sep 7, 2022
For context here openapi-generator does this for python decimal.Decimal amounts with:
karenetheridge commentedon Sep 11, 2022
I could almost see a "number" format being useful, to specify strings that contain numeric data, but there's so many ways of representing a number, and some of them might not be suitable for a particular application. Also some numeric representations aren't practical in some languages.
For example, one could start out defining a number format as "any string that can be converted to a number in my language" -- so for perl, the easy way of implementing that is with
looks_like_number, which handles values like "2.0", "2.5", "2e-3", "Inf" and "NaN" - but doesn't handle "0xDEADBEEF" or "0x1.23p-4" or "0 but true" (which are all treated internally as numbers without warning). Or in C, one could useatoi()but that doesn't match many numeric forms cleanly either.tldr: formats like this are best defined locally to an application using a definition, so it can be tailored to the exact needs of that application, framework and language.