Number.prototype.toHexExponential
This is similar to 'toExponential' but is in the normalised hexadecimal
form instead of decimal.
E.g. 1.4A2p+4
The letter 'p' corresponds to decimal's 'e', and means "times 2 to the
power of".
The *binary* exponent is represented in signed *decimal*.
The hex representation should probably be in lowercase to match that of
'toString(16)'.

GNU's printf provides this format with its %a and %A conversions. The
format is useful for transferring arbitrary binary floating-point values
exactly, whereas decimal formats round them.

Number.prototype.toString() generates as many digits as needed for the number to be representable unambiguously.

(if I wanted packed binary number representation, then rather some form of base32 - it packs more)

True about the decimal representation - the case for unambiguous transfer is weak.

The objective of hexadecimal exponential representation is not to achieve dense packing; rather to represent a binary64 value in a common programmer-friendly (i.e. hexadecimal) form. Note the natural match with the binary64 sign-significand-exponent fields.

Some Prior Art:
1) GNU's printf does this with %a and %A conversions, (other printf versions too?). 2) C (after C99) has hexadecimal exponential literals (see my new post "hexadecimal literals for floating-point"). 3) (I believe) IEEE 754-2008 specifies it.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to