September 2017
Beginner
402 pages
9h 52m
English
The Num type is used to store floating-point values. It corresponds to the double precision in C.
Notice that, in Perl 6, the Num value is only created when the numeric literal is spelled in a scientific notation. That is, the E part of the value must be present.
Thus, in the following examples, the numbers with only a decimal point will be of the Rat type:
say 3.14; # Ratsay 123.456; # Ratsay 0.9; # Rat
The following numbers represent the same values, but are of the Num type, as they use the exponential part in their definition:
say 3.14E0; # Numsay 1.23456E2; # Numsay 9E-1; # Num
Remember that the Num values use the packed IEEE binary format, so they are limited in precision, while Rat numbers keep their numerator and ...
Read now
Unlock full access