Documentation for method Rat assembled from the following pages:
Class: RatStr §
From RatStr
(RatStr) method Rat §
method Rat
Returns the Rat value of the RatStr.
Class: Str §
From Str
(Str) method Rat §
Defined as:
method Rat(Str: --> Rational)
Coerces the string to a Rat object, using the same rules as Str.Numeric. If the denominator is larger than 64-bits is it still kept and no degradation to Num occurs.
Class: Num §
From Num
(Num) method Rat §
method Rat(Num: Real = 1e-6)
Converts the number to a Rat with $epsilon precision. If the invocant is a Inf, -Inf, or a NaN, converts them to a Rat with 0 denominator and 1, -1, or 0 numerator, respectively.
Role: Real §
From Real
(Real) method Rat §
method Rat(Real: Real = 1e-6)
Calls the Bridge method on the invocant and then the Rat method on its return value with the $epsilon argument.
Class: Cool §
From Cool
(Cool) method Rat §
Defined as:
multi method Rat()
Coerces the invocant to a Numeric and calls its .Rat method. Fails if the coercion to a Numeric cannot be done.
say 1+0i.Rat; # OUTPUT: «1» say 2e1.Rat; # OUTPUT: «20» say (-4/3).Rat; # OUTPUT: «-1.333333» say "foo".Rat.^name; # OUTPUT: «Failure» say (.numerator, .denominator) for π.Rat; # OUTPUT: «(355 113)»