AlligatorStamp has asked for the wisdom of the Perl Monks concerning the following question:
Hello. I am having trouble getting Perl to give me correct answers with large numbers. I am using Perl 5.14.2 on Windows.
6^25 = 28430288029929701376.
When I run the following:
my $bigNumber = 6**25; printf ("%.f", $bigNumber);
I get 28430288029929701000.
Assuming that this lack of accuracy was due to 32-bit Perl's trouble with numbers above 2^53, I tried the following:
use Math::BigInt; my $bigNumber = Math::BigInt->new(6**25); print "$bigNumber";
which gives me 28430288029929700000
I don't understand why BigInt is giving me an even less accurate answer.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Math With Big Numbers
by tybalt89 (Monsignor) on Feb 14, 2019 at 20:44 UTC | |
by syphilis (Archbishop) on Feb 14, 2019 at 22:41 UTC | |
Re: Math With Big Numbers
by davido (Cardinal) on Feb 15, 2019 at 06:11 UTC | |
Re: Math With Big Numbers
by pryrt (Abbot) on Feb 14, 2019 at 21:02 UTC | |
Re: Math With Big Numbers
by Cristoforo (Curate) on Feb 14, 2019 at 20:42 UTC | |
Re: Math With Big Numbers
by Laurent_R (Canon) on Feb 14, 2019 at 21:58 UTC | |
Re: Math With Big Numbers
by danaj (Friar) on Mar 26, 2019 at 23:20 UTC |