in reply to Perl 5 numeric type and simplifications

can I rely on this behaviour of simplifying the number?)

Perl's print() function does indeed like to "simplify" numbers, often to an embarrassingly absurd extent.
Here, we see three unequal numbers printed identically:
C:\>perl -e "$x = 1.23456789012345e15; print $x;" 1.23456789012345e+15 C:\>perl -e "$x = 1.234567890123454e15; print $x;" 1.23456789012345e+15 C:\>perl -e "$x = 1.2345678901234544e15; print $x;" 1.23456789012345e+15
Perl knows that all 3 values are different:
C:\>perl -e "print 'different' if 1.23456789012345e15 != 1.23456789012 +3454e15;" different C:\>perl -e "print 'different' if 1.23456789012345e15 != 1.23456789012 +34544e15;" different C:\>perl -e "print 'different' if 1.234567890123454e15 != 1.2345678901 +234544e15;" different
yet happily presents them as identical.
You can't really rely on perl's print() for anything much when floating point values are concerned.

Cheers,
Rob

Replies are listed 'Best First'.