2009/6/3 Kelly Jones <kelly.terry.jo...@gmail.com>:
> 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?
snip

I believe you are well beyond the range of floats, try using bignums instead:

perl -Mbignum -le 'print join " ", 4294967295, 2147483647*2**32,
2147483647*2**32+4294967295'


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to