The problem also seems related to Perl version, but I can't say why. Trying the following code under various Perl versions I have access to ATM:
c:\@Work\Perl\monks>perl -wMstrict -le "print 'perl version: ', $]; ;; $a = '-4.84800000E+001'; $a += 0; $b = -48.48; print 'EQ' if $a == $b; printf qq{%0.20f ?==? %0.20f \n}, $a, $b; " perl version: 5.008009 -48.48000000000000400000 ?==? -48.47999999999999700000 perl version: 5.010001 EQ -48.47999999999999700000 ?==? -48.47999999999999700000 perl version: 5.014004 EQ -48.47999999999999700000 ?==? -48.47999999999999700000
Update: choroba has /msgd to ask if the differences in my results are due to 32- versus 64-bit build differences. As far as I can see from perl -V (and to the best of my recollection), all the Perls I have here are 32-bit. However, the 5.8.9 I'm using is ActiveState, while the others are all Strawberries.
Update: davido /msgd to suggest different C compilers/libraries have different internal implementations for FP handling; perhaps AS Perl was compiled with Visual Studio and Strawberry with GNU/C.
Give a man a fish: <%-{-{-{-<
In reply to Re: Converting -4.84800000E+001 to -48.48 doesn't work... but 48.49 does
by AnomalousMonk
in thread Converting -4.84800000E+001 to -48.48 doesn't work... but 48.49 does
by notameadow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |