in reply to Re: Largest integer in 64-bit perl
in thread Largest integer in 64-bit perl
#!/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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Largest integer in 64-bit perl
by pfaut (Priest) on May 17, 2025 at 00:34 UTC |