Re: [PBML] Bug of the perl?
>>>>> "Chongjian" == Chongjian Chen <biochan@...> writes:Chongjian> Does anyone know what the problem is?
The FAQ is useful to read. Please read it once a week until
you no longer need to read it. On this subject, it suggests:
$ perldoc -q broken
Found in /usr/libdata/perl5/pod/perlfaq4.pod
Why is int() broken?
Your int() is most probably working just fine. It's the numbers that
aren't quite what you think.
First, see the above item "Why am I getting long decimals (eg,
19.9499999999999) instead of the numbers I should be getting (eg,
For example, this
print int(0.6/0.2-2), "\n";
will in most computers print 0, not 1, because even such simple numbers
as 0.6 and 0.2 cannot be presented exactly by floating-point numbers.
What you think in the above as 'three' is really more like
In other words, floats are not precise, and you have to take that
into consideration when working with them. 0.1 is NOT the same as 1/10.
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion