package bigrat;
require "bigint.pl";
-
-# Arbitrary size rational math package
#
+# This library is no longer being maintained, and is included for backward
+# compatibility with Perl 4 programs which may require it.
+# This legacy library is deprecated and will be removed in a future
+# release of perl.
+#
+# In particular, this should not be used as an example of modern Perl
+# programming techniques.
+#
+# Arbitrary size rational math package
+
# by Mark Biggar
#
# Input values to these routines consist of strings of the form
'NaN';
} else {
local($gcd) = &'bgcd($num,$dom);
+ $gcd =~ s/^-/+/;
if ($gcd ne '+1') {
$num = &'bdiv($num,$gcd);
$dom = &'bdiv($dom,$gcd);
# negation
sub main'rneg { #(rat_num) return rat_num
- local($_) = &'rnorm($_[0]);
+ local($_) = &'rnorm(@_);
tr/-+/+-/ if ($_ ne '+0/1');
$_;
}
# absolute value
sub main'rabs { #(rat_num) return $rat_num
- local($_) = &'rnorm($_[0]);
+ local($_) = &'rnorm(@_);
substr($_,0,1) = '+' unless $_ eq 'NaN';
$_;
}
# int and frac parts
sub main'rmod { #(rat_num) return (rat_num,rat_num)
- local($xn,$xd) = split('/',&'rnorm($_[0]));
+ local($xn,$xd) = split('/',&'rnorm(@_));
local($i,$f) = &'bdiv($xn,$xd);
if (wantarray) {
("$i/1", "$f/$xd");