method norm

Documentation for method norm assembled from the following types:

role Rational

From Rational

(Rational) method norm

method norm(Rational:D: --> Rational:D)

DEPRECATED as of 6.d. The method is no longer needed, because as of 6.d language version, it's required for Rational type to be normalized on creation.

Returns a normalized Rational object, i.e. with positive denominator, and numerator and denominator coprime. The denominator can also by zero, but using it in any operation or a conversion to string will result in an exception.

use v6.c;
my Rational $by-zero = 3/0;
say $by-zero.norm.perl# OUTPUT: «<1/0>␤» 
say $by-zero# OUTPUT: «Attempt to divide by zero when coercing Rational to Str␤