September 2017
Beginner
402 pages
9h 52m
English
In Perl 6, a special type Rat exists to store the rational numbers. In many cases, Rat will be used when you deal with floating-point numbers. Internally, the Rat value is represented by a pair of integer values, numerators, and denominators. Thus, any Rat number is a rational value equal to the division N/D. The integer numerator part is a value that can be arbitrarily long. The denominator part is a 64-bit integer.
Rat values appear as soon as you have a constant with the decimal point without an exponential part. Consider the following example:
say 3.14;
The 3.14 literal creates a Rat value here.
There is another syntax to create a Rat value: use the slash as in division and, optionally, enclose a number in the pair ...