in reply to Arithmetic on numbers bigger than 1<<31
use Math::BigInt; # or make it faster: install (optional) Math::BigInt::GMP # and always use (it will fall back to pure Perl if the # GMP library is not installed): use Math::BigInt lib => 'GMP'; my $str = '1234567890'; $x = Math::BigInt->new($str); # defaults to 0 $y = $x->copy(); # make a true copy $x->badd($y); # addition (add $y to $x) $x->bsub($y); # subtraction (subtract $y from $x) $x->bstr(); # convert to a normalized string $x->bsstr(); # normalized string in scientific no +tation $x->as_hex(); # as signed hexadecimal string with +prefixed 0x $x->as_bin(); # as signed binary string with prefi +xed 0b # etc.
-Mark
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Arithmetic on numbers bigger than 1<<31 (not so big)
by tye (Sage) on May 13, 2004 at 20:15 UTC |