[Newbies] Float comparsion

Lukas Renggli renggli at gmail.com
Fri Feb 27 12:34:15 UTC 2009


Hi Camillo ;-)

Use the method #closeTo: instead of #=. Comparing floats with #=
almost never works.

Although "(Float halfPi / 2) tan" is printed as 1.0, it is not exactly
1.0 due to rounding errors in the calucaltaion and/or the internal
representation.

    (Float halfPi / 2) tan - 1.0 --> -1.110223024625156e-16

Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch


More information about the Beginners mailing list