Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Bug of the perl?

Expand Messages
  • merlyn@stonehenge.com
    ... 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
    Message 1 of 2 , Jul 18, 2008
    • 0 Attachment
      >>>>> "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,
      19.95)?".

      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
      2.9999999999999995559.

      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.
      Ever.

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
      See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
    Your message has been successfully submitted and would be delivered to recipients shortly.