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

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.

主站蜘蛛池模板: 新津县| 藁城市| 台州市| 仁怀市| 富川| 湛江市| 德惠市| 井研县| 北川| 彰武县| 洪雅县| 德江县| 祁阳县| 壤塘县| 北京市| 襄垣县| 东港市| 黄石市| 涪陵区| 巴南区| 琼海市| 万宁市| 株洲市| 岳西县| 双鸭山市| 徐汇区| 霍林郭勒市| 邵武市| 泰州市| 博乐市| 屯昌县| 枣强县| 北碚区| 南宫市| 和林格尔县| 乌恰县| 三明市| 长阳| 普兰县| 永丰县| 贵定县|