If you've had prior experience with other programming languages (like C, FORTRAN or assembler), you know that there are basically two different ways of storing numeric values (i.e. two different types of numeric data): integer and floating point, and that there are fundamental differences in the cpu operations that perform arithmetic on these two types (integer operations are "exact" in value but limited in range, floating point ops are relatively "approximate" in value but relatively unlimited in range).

As you use more bits to store integer numbers (lots of cpus are using 64 bits these days), you get to do arithmetic over a larger range, and it will always be exact in the integer domain (where fractional values do not exist). As you use more bits to store floating-point numbers (cpus have been supporting 64-bit floats for a long time now), you get to do arithmetic over a much larger range with greater accuracy.

These considerations used to demand more attention from programmers, back when it was a lot harder, slower and/or more expensive to use more bits for numbers. These days, it still matters to some people who handle values or differences of extremely large or extremely small magnitude, but for most folks, it's just not an issue any more. With all arithmetic being done in 64-bit floating point, you don't start losing exactness in the integer domain until you get up around 2**50. And although speed of computation can be an issue, usually it is not (and in the rare cases where it is a killer issue, you shouldn't be doing the arithmetic in Perl anyway -- use C instead).

Bottom line: don't worry about it. If you want things like "13/5" to produce an integer result, just do "int( 13/5 )".

20040928 Edit by Corion: Changed title from 'Re: Don't understand, what this means'


In reply to Re: Confusion Regarding Perl's Numerical Handling by graff
in thread Confusion Regarding Perl's Numerical Handling by Anonymous Monk

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.