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

Getting the sign of the value

The sign method (also inherited from the Real role) returns either -1 or 1, depending on the sign of the value. Consider the following code snippet:

say 42.sign;  # 1
say -42.sign; # -1

The result of calling the method on zero is 0, as shown here:

say 0.sign; # 0

The sign method also works with infinities:

say Inf.sign;  # 1
say (-∞).sign; # -1
主站蜘蛛池模板: 文成县| 安平县| 施秉县| 鄂尔多斯市| 仁化县| 巴林左旗| 丹巴县| 乌苏市| 漾濞| 嫩江县| 威信县| 丹阳市| 阿城市| 鄂托克旗| 弥勒县| 那坡县| 南昌市| 清水河县| 呈贡县| 通海县| 邵武市| 石台县| 大关县| 双城市| 阳泉市| 陆川县| 天峻县| 凤山县| 师宗县| 页游| 望都县| 涡阳县| 远安县| 玛多县| 高邑县| 栾城县| 开阳县| 横山县| 乌兰县| 华容县| 岳普湖县|