in reply to Re^2: Okay! What!?!?!?
in thread Okay! What!?!?!?

Sorry for misreading your question.

It's (again) a floating point problem.

DB<149> $a=14.4 => "14.4" DB<150> $b=10+$a-10 => "14.4" DB<151> $a-$b => "1.77635683940025e-15"

The mantissa does loose some digits at the end after adding 10 and substracting doesn't bring them back.

A proper test is either to stay integer from the beginning till the end or to calculate the difference and to compare against a threshold (trickier).

Please note how 14.5 doesn't have this problem since 1/2 is a power of 2 (i.e. only 0s are lost when shifting the mantissa)

update
see Re: eq vs == and Humans have too many fingers for more details

Cheers Rolf

( addicted to the Perl Programming Language)