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

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
主站蜘蛛池模板: 镇江市| 邳州市| 乐亭县| 海城市| 汽车| 莱芜市| 肇庆市| 平阴县| 来安县| 镇坪县| 饶平县| 尉氏县| 临泉县| 元朗区| 桐柏县| 霸州市| 和田县| 奉节县| 乐平市| 平陆县| 三亚市| 双牌县| 南江县| 化隆| 凌海市| 宁陵县| 措美县| 云林县| 三门县| 漳州市| 泰安市| 监利县| 金川县| 萨迦县| 马尔康县| 廊坊市| 锦州市| 鲁甸县| 苏尼特左旗| 宝兴县| 商都县|