X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fbigint.pl;h=4044f7f6348379e67a01adafaca46578697c18b8;hb=0994714a4e4e0304c91b2fa0c73d50669931b7e2;hp=a274736e44187ca6e3e5278cd8cc788a8494ed91;hpb=1e2e1ae8d60a2653b0297f8d75f9d4fe5abfc82b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/bigint.pl b/lib/bigint.pl index a274736..4044f7f 100644 --- a/lib/bigint.pl +++ b/lib/bigint.pl @@ -1,5 +1,13 @@ package bigint; - +# +# This library is no longer being maintained, and is included for backward +# compatibility with Perl 4 programs which may require it. +# +# In particular, this should not be used as an example of modern Perl +# programming techniques. +# +# Suggested alternative: Math::BigInt +# # arbitrary size integer math package # # by Mark Biggar @@ -74,7 +82,7 @@ sub external { #(int_num_array) return num_str sub main'bneg { #(num_str) return num_str local($_) = &'bnorm(@_); vec($_,0,8) ^= ord('+') ^ ord('-') unless $_ eq '+0'; - s/^H/N/; + s/^./N/ unless /^[-+]/; # works both in ASCII and EBCDIC $_; } @@ -168,11 +176,11 @@ sub add { #(int_num_array, int_num_array) return int_num_array $car = 0; for $x (@x) { last unless @y || $car; - $x -= 1e5 if $car = (($x += shift(@y) + $car) >= 1e5); + $x -= 1e5 if $car = (($x += shift(@y) + $car) >= 1e5) ? 1 : 0; } for $y (@y) { last unless $car; - $y -= 1e5 if $car = (($y += $car) >= 1e5); + $y -= 1e5 if $car = (($y += $car) >= 1e5) ? 1 : 0; } (@x, @y, $car); }