method FatRat

Documentation for method FatRat assembled from the following types:

class Num

From Num

(Num) method FatRat

method FatRat(Num:D: Real $epsilon = 1e-6)

Converts the number to a FatRat with the precision $epsilon. If invocant is a Inf, -Inf, or a NaN, converts them to a FatRat with 0 denominator and 1, -1, or 0 numerator, respectively.

class Cool

From Cool

(Cool) method FatRat

Defined as:

multi method FatRat()

Coerces the invocant to a Numeric and calls its .FatRat method. Fails if the coercion to a Numeric cannot be done.

say 1+0i.FatRat;          # OUTPUT: «1␤» 
say 2e1.FatRat;           # OUTPUT: «20␤» 
say 1.3.FatRat;           # OUTPUT: «1.3␤» 
say (-4/3).FatRat;        # OUTPUT: «-1.333333␤» 
say "foo".FatRat.^name;   # OUTPUT: «Failure␤»