Hi Kelly,
Kelly Jones wrote:
perl -le 'printf("%f %f %f\n", 4294967295, 2147483647*2**32, 2147483647*2**32+4294967295)' 4294967295.000000 9223372032559808512.000000 9223372036854775808.000000 Why? The answer is really 9223372036854775807 (one number lower), and it's obvious that adding 2 and 5 in the units column should yield a 7 in the sum's unit column. Roundoff error? Bug? How do I work around it?
I guess it is a problem with floating point arithmetic where no floating point value can be represented exactly by a computer. Take a look at:
http://docs.sun.com/source/806-3568/ncg_goldberg.html For what it's worth, if you change %f to %u, it works fine [for me, anyway]: perl -le 'printf("%u %u %u\n", 4294967295, 2147483647*2**32, 2147483647*2**32+4294967295)' 4294967295 9223372032559808512 9223372036854775807 Ray -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/