Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (22 sloc) 1.15 KB
=begin pod
=TITLE class FatRat
=SUBTITLE Rational number (arbitrary-precision)
class FatRat is Cool does Rational[Int, Int] {}
A C<FatRat> is a rational number stored with arbitrary size numerator and
denominator. Arithmetic operations involving a C<FatRat> and optionally L<Int|/type/Int>
or L<Rat|/type/Rat> objects return a C<FatRat>, avoiding loss of precision.
Since, unlike L<Rat|/type/Rat>, FatRat arithmetics do not fall back L<Num|/type/Num> at some
point, there is a risk that repeated arithmetic operations generate
pathologically large numerators and denominators.
There are two common ways to generate C<FatRat> objects: through the
C<, Int)> constructor, which generates them from numerator and
denominator, or by calling the C<.FatRat> method on an L<Int|/type/Int> or L<Rat|/type/Rat>
=head1 Methods
=head2 method perl
multi method perl(FatRat:D: --> Str:D)
Returns an implementation-specific string that produces an L<equivalent|/routine/eqv> object
when given to L<EVAL|/routine/EVAL>.
say, 2).perl; # OUTPUT: «, 2)␤»
=end pod
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
You can’t perform that action at this time.