lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> But if your hands are tied with JSON or similar formats - or you want
> human-readability - you need to format as decimal.  This can't be
> exact, [...]

It most certainly can.

Infinities and NaNs excepted, every IEEE float value can be represented
exactly as a sum of no more than 53 (or is it 54? I'd have to go check;
something <60, at any rate) powers of two.  And every power of two has
an exact decimal representation.  And, of course, the sum of a finite
number of exact decimal representations is also exact.

Of course, if the float's exponent is large, either large and positive
or large and negative, the exact decimal representation may be rather
lengthy.  But it exists.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse@rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B