-
Notifications
You must be signed in to change notification settings - Fork 701
Closed
Description
I'm opening up a can of bikeshed: how should the textual WebAssembly format represent floating-point numbers?
This has nothing to do with the binary format.
Keep in mind:
- Currently we support
f32andf64. - We'll eventually support vectors of these types.
- Must support NaN properly.
- Do we support a leading sign?
- We don't differentiate between different NaN types at the moment. Do we allow n-char-sequence after NaN as
printfdoes? - How do we capitalize NaN (if we represent it as text at all)?
nanNaNNAN.
- Must support
±infinity.- How do we spell it (if we represent it as text at all)?
infinityINFINITYinfINF∞.
- How do we spell it (if we represent it as text at all)?
- Must support
±0. - Must support denormals, but that's likely a non-issue.
- Not all numbers are accurately representable as
f32orf64: decimal (e.g.3.141592) and exponential (e.g.6.022140e23) often have such non-representable numbers that need to be rounded somehow. - We can support multiple inputs for programmer's convenience, but then we're making the text format parser more complex (which doesn't really matter).
A few ideas:
- little-endian hexadecimal representation of the IEEE-754 number (e.g.
0x7FF8000000000000is positive NaN with0bits). This is effectively areinterpret_castfrom integer to floating-point. - C99 hexadecimal floating-point (e.g.
0x1p1is 2.0). - Precisely-representable decimal and exponential notations only.
- Any decimal and exponential notation, with a spec-mandated rounding.
Or a combination of the above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels