The FatRat routine

Combined from primary sources listed below.

In class Num ( Type/Num )§

See primary docmentation in context for method FatRat.

method FatRat§

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

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

In class Cool ( Type/Cool )§

See primary docmentation in context for method FatRat.

method FatRat§

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␤»