OAI / OpenAPI-Specification

The OpenAPI Specification Repository
https://openapis.org
Apache License 2.0
28.94k stars 9.07k forks source link

Guidance for float and double max and min values #2570

Closed spacether closed 9 months ago

spacether commented 3 years ago

Hi there Can we get some guidance on

type: number
format: float

and

type: number
format: double

Maximum and minimum values? It sounds like Some floating point formats use an unrepresented hidden 1 bit in the mantissa (this allows for one extra bit of precision in the mantissa per https://softwareengineering.stackexchange.com/questions/294269/how-to-calculate-min-max-values-of-floating-point-numbers

  1. Should float be a single-precision 32-bit IEEE 754 floating point?
  2. Should double be a double-precision 64-bit IEEE 754 floating point?
MikeRalphson commented 3 years ago

I believe the intention was to refer to the IEEE754 definitions, but we should make this explicit. Do you have time to work up a PR against the v3.1.1-dev branch? A more full description should also go into new entries in the formats registry - this would be a PR against the gh-pages branch.

spacether commented 3 years ago

Right now I don't have time to do this sorry. It would also help to specify if the floats are binary32 and are not decimal32. Should the formats registry be versioned or referred to via commit hash? That allows the spec to point to specific approved format values.

handrews commented 9 months ago

This has since been addressed by multiple additions to the formats registry around floating point and decimal representations.