I wrote some test program printing the values of ~0 and 2**64:
#!/usr/bin/perl
use warnings;
use strict;
#use integer;
print ~0, "\n";
print 2**64, "\n";
Without use integer the program outputs
118446744073709551615
1.184467440737096e+19
With use integer the program outputs:
-1
1.184467440737096e+19
The other odd thing is that even when using print int(2**64) the number is output in scientific format still, just as if int(...) wasn't there (Still ~0 without use integer is output in "integer format").
I can force integer output using printf("%u\n", ...), however.
(Perl being used in 5.18.2 of SLES12 SP5 on x86_64)
Questions:
So why is 2**64 a "float" with and without use integer, while ~0 never is?
And with use integer when ~0 is print as -1, it still satisfies the condition ~0 > 2**63 (when I'd expect -1 not to be greater than any positive value (like 2**63).
Update
There seems to be another odd effect seen in the Perl debugger:
2^64 is an odd integer, and 2^64-1 is -2.
DB<22> if (1) { use integer; print 2**64, "\n" }
1.84467440737096e+19
DB<23> if (1) { use integer; print 2**64 - 1, "\n" }
-2
DB<13> if (1) { use integer; printf '%x', 2**64-1, "\n" }
fffffffffffffffe
DB<14> if (1) { use integer; printf '%x', 2**64, "\n" }
ffffffffffffffff
DB<15> if (1) { no integer; printf '%x', 2**64, "\n" }
ffffffffffffffff
DB<16> if (1) { no integer; printf '%x', 2**63, "\n" }
8000000000000000