This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8.c: Modify doc comment; change whitespace
[perl5.git] / lib / bigrat.pl
index fb10cf3..6f5905f 100644 (file)
@@ -1,8 +1,16 @@
 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 
@@ -55,6 +63,7 @@ sub norm { #(bint, bint) return rat_num
        'NaN';
     } else {
        local($gcd) = &'bgcd($num,$dom);
+       $gcd =~ s/^-/+/;
        if ($gcd ne '+1') { 
            $num = &'bdiv($num,$gcd);
            $dom = &'bdiv($dom,$gcd);
@@ -69,14 +78,14 @@ sub norm { #(bint, bint) return rat_num
 
 # 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';
     $_;
 }
@@ -118,7 +127,7 @@ sub main'rcmp { #(rat_num, rat_num) return cond_code
 
 # 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");