FatRat
ErrorsCollection

FatRat

Synthesised documentation from type/Num type/Cool

From type/Num

See Original text in context

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.

From type/Cool

See Original text in context

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