Hi Bill,
Perl 6 is converting fractional numbers not into floating-point numbers as most languages, but into Rat (rational) type values. Internally, rational type numbers are in fact made of pairs of integer numbers, one for the numerator and one for the denominator, stored separately. So the numeric literal 319.02 is stored internally as something like (numerator = 31902, denominator = 100). When making arithmetic operations on such numbers, Perl 6 will happily add (or subtract) the integers and then print the result as a rational number. The result is accurate because there is no use of floating-point number approximation.
Consider the following code introspecting the types of values and variables:
> say 42.WHAT;
(Int)
> say 319.02.WHAT;
(Rat)
> say $x.WHAT;
(Rat)
|