Odd problem

ant at badmagic.com ant at badmagic.com
Mon Apr 21 07:26:46 PDT 2008

> So, it thinks that '1.6771678' is different from '1.6771678'; Any ideas anyone ?

Its been a while since I wrote any perl...

But, imho, you are using a numerical comparison of floating point numbers, so all bets are off - it could do anything (in almost any language, not just perl)!. The fact that it differs on each OS is just an indicator, you would probably get the same behaviour on the same OS for different floating point numbers.


If you really know the format of the numbers, eg, leading zeros removed etc, you could use string comparison, but its better to use a proper approximation function as per the perl monks node above. Unfortunately it forces you to know about precision that you would probably rather not have to think about.


More information about the MiltonKeynes-pm mailing list