diff options
Diffstat (limited to 'Master/tlpkg/tlperl/lib/bigfloat.pl')
-rw-r--r-- | Master/tlpkg/tlperl/lib/bigfloat.pl | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/Master/tlpkg/tlperl/lib/bigfloat.pl b/Master/tlpkg/tlperl/lib/bigfloat.pl index dd0bc05af2f..82d0f5c4df6 100644 --- a/Master/tlpkg/tlperl/lib/bigfloat.pl +++ b/Master/tlpkg/tlperl/lib/bigfloat.pl @@ -1,3 +1,5 @@ +warn "Legacy library @{[(caller(0))[6]]} will be removed from the Perl core distribution in the next major release. Please install it from the CPAN distribution Perl4::CoreLibs. It is being used at @{[(caller)[1]]}, line @{[(caller)[2]]}.\n"; + package bigfloat; require "bigint.pl"; # @@ -79,7 +81,7 @@ sub norm { #(mantissa, exponent) return fnum_str # negation sub main'fneg { #(fnum_str) return fnum_str - local($_) = &'fnorm($_[$[]); + local($_) = &'fnorm($_[0]); vec($_,0,8) ^= ord('+') ^ ord('-') unless $_ eq '+0E+0'; # flip sign if ( ord("\t") == 9 ) { # ascii s/^H/N/; @@ -92,14 +94,14 @@ sub main'fneg { #(fnum_str) return fnum_str # absolute value sub main'fabs { #(fnum_str) return fnum_str - local($_) = &'fnorm($_[$[]); + local($_) = &'fnorm($_[0]); s/^-/+/; # mash sign $_; } # multiplication sub main'fmul { #(fnum_str, fnum_str) return fnum_str - local($x,$y) = (&'fnorm($_[$[]),&'fnorm($_[$[+1])); + local($x,$y) = (&'fnorm($_[0]),&'fnorm($_[1])); if ($x eq 'NaN' || $y eq 'NaN') { 'NaN'; } else { @@ -111,7 +113,7 @@ sub main'fmul { #(fnum_str, fnum_str) return fnum_str # addition sub main'fadd { #(fnum_str, fnum_str) return fnum_str - local($x,$y) = (&'fnorm($_[$[]),&'fnorm($_[$[+1])); + local($x,$y) = (&'fnorm($_[0]),&'fnorm($_[1])); if ($x eq 'NaN' || $y eq 'NaN') { 'NaN'; } else { @@ -124,7 +126,7 @@ sub main'fadd { #(fnum_str, fnum_str) return fnum_str # subtraction sub main'fsub { #(fnum_str, fnum_str) return fnum_str - &'fadd($_[$[],&'fneg($_[$[+1])); + &'fadd($_[0],&'fneg($_[1])); } # division @@ -132,7 +134,7 @@ sub main'fsub { #(fnum_str, fnum_str) return fnum_str # result has at most max(scale, length(dividend), length(divisor)) digits sub main'fdiv #(fnum_str, fnum_str[,scale]) return fnum_str { - local($x,$y,$scale) = (&'fnorm($_[$[]),&'fnorm($_[$[+1]),$_[$[+2]); + local($x,$y,$scale) = (&'fnorm($_[0]),&'fnorm($_[1]),$_[2]); if ($x eq 'NaN' || $y eq 'NaN' || $y eq '+0E+0') { 'NaN'; } else { @@ -159,13 +161,13 @@ sub round { #(int_str, int_str, int_str) return int_str if ( $cmp < 0 || ($cmp == 0 && ( $rnd_mode eq 'zero' || - ($rnd_mode eq '-inf' && (substr($q,$[,1) eq '+')) || - ($rnd_mode eq '+inf' && (substr($q,$[,1) eq '-')) || + ($rnd_mode eq '-inf' && (substr($q,0,1) eq '+')) || + ($rnd_mode eq '+inf' && (substr($q,0,1) eq '-')) || ($rnd_mode eq 'even' && $q =~ /[24680]$/) || ($rnd_mode eq 'odd' && $q =~ /[13579]$/) )) ) { $q; # round down } else { - &'badd($q, ((substr($q,$[,1) eq '-') ? '-1' : '+1')); + &'badd($q, ((substr($q,0,1) eq '-') ? '-1' : '+1')); # round up } } @@ -173,7 +175,7 @@ sub round { #(int_str, int_str, int_str) return int_str # round the mantissa of $x to $scale digits sub main'fround { #(fnum_str, scale) return fnum_str - local($x,$scale) = (&'fnorm($_[$[]),$_[$[+1]); + local($x,$scale) = (&'fnorm($_[0]),$_[1]); if ($x eq 'NaN' || $scale <= 0) { $x; } else { @@ -181,8 +183,8 @@ sub main'fround { #(fnum_str, scale) return fnum_str if (length($xm)-1 <= $scale) { $x; } else { - &norm(&round(substr($xm,$[,$scale+1), - "+0".substr($xm,$[+$scale+1,1),"+10"), + &norm(&round(substr($xm,0,$scale+1), + "+0".substr($xm,$scale+1,1),"+10"), $xe+length($xm)-$scale-1); } } @@ -190,7 +192,7 @@ sub main'fround { #(fnum_str, scale) return fnum_str # round $x at the 10 to the $scale digit place sub main'ffround { #(fnum_str, scale) return fnum_str - local($x,$scale) = (&'fnorm($_[$[]),$_[$[+1]); + local($x,$scale) = (&'fnorm($_[0]),$_[1]); if ($x eq 'NaN') { 'NaN'; } else { @@ -206,11 +208,11 @@ sub main'ffround { #(fnum_str, scale) return fnum_str # we'll pass a non-normalized "-0" to &round when rounding # -0.006 (for example), purely so that &round won't lose # the sign. - &norm(&round(substr($xm,$[,1).'0', - "+0".substr($xm,$[+1,1),"+10"), $scale); + &norm(&round(substr($xm,0,1).'0', + "+0".substr($xm,1,1),"+10"), $scale); } else { - &norm(&round(substr($xm,$[,$xe), - "+0".substr($xm,$[+$xe,1),"+10"), $scale); + &norm(&round(substr($xm,0,$xe), + "+0".substr($xm,$xe,1),"+10"), $scale); } } } @@ -220,14 +222,14 @@ sub main'ffround { #(fnum_str, scale) return fnum_str # returns undef if either or both input value are not numbers sub main'fcmp #(fnum_str, fnum_str) return cond_code { - local($x, $y) = (&'fnorm($_[$[]),&'fnorm($_[$[+1])); + local($x, $y) = (&'fnorm($_[0]),&'fnorm($_[1])); if ($x eq "NaN" || $y eq "NaN") { undef; } else { ord($y) <=> ord($x) || ( local($xm,$xe,$ym,$ye) = split('E', $x."E$y"), - (($xe <=> $ye) * (substr($x,$[,1).'1') + (($xe <=> $ye) * (substr($x,0,1).'1') || &bigint'cmp($xm,$ym)) ); } @@ -235,7 +237,7 @@ sub main'fcmp #(fnum_str, fnum_str) return cond_code # square root by Newtons method. sub main'fsqrt { #(fnum_str[, scale]) return fnum_str - local($x, $scale) = (&'fnorm($_[$[]), $_[$[+1]); + local($x, $scale) = (&'fnorm($_[0]), $_[1]); if ($x eq 'NaN' || $x =~ /^-/) { 'NaN'; } elsif ($x eq '+0E+0') { |