B
bwooster47
On my machine, perl -V:ivsize returns
ivsize='4';
This I thought meant that 4-byte integers are supported, so max
integer is probably 2billion or 4billion (approximately).
But - I seem to be able to add much larger numbers, and stay in
integer space - such as 51 billion.
The exponentiation operator does internally use "double", but it still
seems to return very large integers, only breaking at around 10^15, as
this output shows:
2**50 = 1.12589990684262e+015
2**49 = 562949953421312
2**32 = 4294967296
with
use bigint;
2**50 = 1125899906842624
If I know the maximum integer I may encounter in a program, is there a
programmatic way to determine whether to use bigint? Doing a "use
bigint" slows down the whole thing by 40 times, in the example I am
running, and a few tests I ran show same results with and without
bigint.
But - how to know for sure that I don't need bigint - if I know that
all calculations to 2**49 are safe, that would make it sure. But not
sure what is so magic about 2**49!
ivsize='4';
This I thought meant that 4-byte integers are supported, so max
integer is probably 2billion or 4billion (approximately).
But - I seem to be able to add much larger numbers, and stay in
integer space - such as 51 billion.
The exponentiation operator does internally use "double", but it still
seems to return very large integers, only breaking at around 10^15, as
this output shows:
2**50 = 1.12589990684262e+015
2**49 = 562949953421312
2**32 = 4294967296
with
use bigint;
2**50 = 1125899906842624
If I know the maximum integer I may encounter in a program, is there a
programmatic way to determine whether to use bigint? Doing a "use
bigint" slows down the whole thing by 40 times, in the example I am
running, and a few tests I ran show same results with and without
bigint.
But - how to know for sure that I don't need bigint - if I know that
all calculations to 2**49 are safe, that would make it sure. But not
sure what is so magic about 2**49!