OK; it's not weird; it's normal behavior for floating point numbers. Back when I started programming (on a Univac 1108, which used 48 bit reals, and could distinguish 0 from -0), one of the first comments by the instructors was "Do not test floating point numbers for equality." It's still good advice; see "What Every Computer Scientist Should Know About Floating-Point Arithmetic"(Goldberg, David, "What Every Computer Scientist Should Know About Floating-Point Arithmetic", Computing Surveys, March 1991).

As a (believe it or not) relevant aside: Fortran-77 permitted floating point numbers be used for do loop counters (== Perl's for(($x=1; $x <= 2; $x += 0.1)); I believe that they're being removed from the latest standard because there was a) no way they could get them to work portably (a given loop may iterate 1000 times on one platform and 1003 on another) and b) they make it difficult to parallelize the do-loop.


emc

Information about American English usage here and here.

Any Northeastern US area jobs? I'm currently unemployed.


In reply to Re: When is a 2 not a 2? by swampyankee
in thread When is a 2 not a 2? by RockM66

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.