On 3/14/07, louis fridkis <[EMAIL PROTECTED]> wrote:

Why does Perl say 10.2 is 10.19999999999

Because it is.

Within the limits of precision of your floating point format, you're
talking about the same number.

This isn't just Perl; every programming language has _something_ like
this. Some hide it more than others, of course. But no computer can do
arithmetic with "real" numbers just like a mathematician does. So we
use floating point as an approximation. In some cases, it causes
unexpected results, as you found.

If you need more precision, Perl has extended precision math modules
available on CPAN. This doesn't solve the problem, of course; but it
can hide it well enough for most purposes.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to