On 2/20/2012 7:46 AM, Steve wrote:
> My guess is it's because .000001 cannot be expressed exactly as a
> float. Like base 10 cannot express 1/3, IEEE floats have trouble with
> 1/10 and derivatives.
>
> Steve
Yes, that's right, 0.000001f is not exactly representable with an IEEE
floating point number. I suspect that the OP's original 9.9534e-7 is the
closest a 64 bit FP number can get to 0.000001f. Its one reason why you
must be very careful with expressions like:
if (fpnumber == 0.000001f) then
And, of course, the original java.lang.Float gets converted to a JS
equivalent which is (almost) the same as a java.lang.Double in JS - but
will still have the same precision when emulated in hosted mode - so,
beware!
In my code I rarely, if ever, use floats anymore, especially if I think
that they are going to be used in GWT. The issues of additional
serialization payload are best solved by compression.
Alan