norm
ErrorsCollection

norm

Synthesised documentation from type/Rational

From type/Rational

See Original text in context

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.raku# OUTPUT: «<1/0>␤» 
say $by-zero# OUTPUT: «Attempt to divide by zero when coercing Rational to Str␤