官术网_书友最值得收藏!

Numeric data type

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;    # Rat
say 123.456; # Rat
say 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;    # Num
say 1.23456E2; # Num
say 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 denominator as two integer numbers.

Among the Num values, there is one outstanding value of NaN, which stands for Not a Number.

主站蜘蛛池模板: 罗山县| 北流市| 孝昌县| 聂荣县| 耒阳市| 宿迁市| 清徐县| 贵州省| 桑日县| 罗源县| 清水河县| 两当县| 新宁县| 平舆县| 望奎县| 平乐县| 平潭县| 芒康县| 凌海市| 同德县| 宜黄县| 江津市| 五大连池市| 崇文区| 长岭县| 莱芜市| 泰州市| 广水市| 东至县| 孝感市| 常宁市| 筠连县| 青龙| 尉氏县| 从化市| 财经| 集贤县| 泰顺县| 东乌珠穆沁旗| 司法| 台湾省|