in reply to Re: bignum usage?
in thread bignum usage?
off-by-one error
It seems you've hit some precision limit - which is avoided if you use bigint.
Try placing an extra number at the beginning of $x, and you'll soon see what I mean.
For every extra number you prepend to the start of $x, you get an extra "0" at the end of $y:
Rob
It seems you've hit some precision limit - which is avoided if you use bigint.
Try placing an extra number at the beginning of $x, and you'll soon see what I mean.
For every extra number you prepend to the start of $x, you get an extra "0" at the end of $y:
Cheers,use strict; use warnings; use feature 'say'; use bignum;#num; # (1) #use bignum downgrade => "Math::BigInt", upgrade => "Math::BigI +nt"; ## (2) #use bigint; say $^V; my $x = 999999999921778071482940061661655974875633165533182; say $x; my $y = $x / 2; say $y; __END__ For me, outputs: D:\pscrpt>perl try.pl v5.39.5 999999999921778071482940061661655974875633165533182 499999999960889035741470030830827987437800000000000
Rob
In Section
Seekers of Perl Wisdom