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

  • Perl 6 Deep Dive
  • Andrew Shitov
  • 163字
  • 2021-07-03 00:05:52

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.

主站蜘蛛池模板: 遂昌县| 阿拉善盟| 鄂托克前旗| 元谋县| 临洮县| 德安县| 双辽市| 临西县| 昭通市| 广饶县| 五常市| 嘉义县| 阿尔山市| 白水县| 浏阳市| 西乌珠穆沁旗| 阳原县| 资溪县| 道真| 万载县| 东安县| 北流市| 剑川县| 大厂| 巩义市| 确山县| 峨山| 铁岭市| 新泰市| 马关县| 三江| 讷河市| 香河县| 青海省| 延边| 万州区| 贺州市| 高台县| 蒙自县| 进贤县| 萍乡市|