Interestingly, the "use integer" line did absolutely nothing for me on 32-bit Windows XP TinyPerl 5.8. I tried to run it on Linux with 64-bit Perl 5.36, and to my surprise, it didn't even run! :-O It produced no error message and no output at all. The program does have a for loop in it, but it looked like it didn't even start the loop. I don't understand... Here's the program again:

#!/usr/bin/perl use strict; use warnings; use integer; $| = 1; my $MAXQUAD = 18446744073709551615; for (my $i = 9007199254740000; $i <= $MAXQUAD; $i++) { printf("\n %.0f %d", $i, $i); }

So, anyway, I did notice that if I remove the "use integer" line, then the program runs. In fact, if I started the loop at, let's say, 4611686018420000000, then it will keep counting on the 64-bit Perl in Linux. Interesting!

However, when I stop the program by pressing CTRL+C, I notice something else. When printing the number $i as float, it sort of loses precision, but when printing it as %d number, it prints it precisely. In TinyPerl, I had the opposite experience with this where %f printed more precise values than %d. This is so weird... :P

4611686018420022272 4611686018420022338 4611686018420022272 4611686018420022339 4611686018420022272 4611686018420022340 4611686018420022272 4611686018420022341 4611686018420022272 4611686018420022342 4611686018420022272 4611686018420022343 4611686018420022272 4611686018420022344 4611686018420022272 4611686018420022345 4611686018420022272 4611686018420022346 4611686018420022272 4611686018420022347 4611686018420022272 4611686018420022348 4611686018420022272 4611686018420022349 4611686018420022272 4611686018420022350

In reply to Re^2: Largest integer in 64-bit perl by harangzsolt33
in thread Largest integer in 64-bit perl by harangzsolt33

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.