Skip to content

Commit

Permalink
Rat degradation example.
Browse files Browse the repository at this point in the history
  • Loading branch information
cfa committed Feb 22, 2019
1 parent fba25f8 commit a004865
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions doc/Language/numerics.pod6
Expand Up @@ -210,8 +210,20 @@ say ½ + ⅓ + ⅝ + ⅙; # OUTPUT: «1.625␤»
If a I<mathematical operation> that produces a L<Rat|/type/Rat> answer would produce
a L<Rat|/type/Rat> with denominator larger than 64 bits, that operation would instead
return a L<Num|/type/Num> object. When I<constructing> a L<Rat|/type/Rat> (i.e. when it is not
a result of some mathematical expression), however, a "fattish" L<Rat|/type/Rat> with
larger denominator will be created.
a result of some mathematical expression), however, a larger denominator can be used:
my $a = 1 / (2⁶⁴ - 1);
say $a; # OUTPUT: «0.000000000000000000054␤»
say $a.^name; # OUTPUT: «Rat␤»
my $b = 1 / 2⁶⁴;
say $b; # OUTPUT: «5.421010862427522e-20␤»
say $b.^name; # OUTPUT: «Num␤»
my $c = Rat.new(1, 2⁶⁴);
say $c; # OUTPUT: «0.000000000000000000054␤»
say $c.^name; # OUTPUT: «Rat␤»
say $c.Num; # OUTPUT: «5.421010862427522e-20␤»
=head2 C<FatRat>
Expand Down

0 comments on commit a004865

Please sign in to comment.