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

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
主站蜘蛛池模板: 科技| 扎鲁特旗| 来安县| 内江市| 商洛市| 荃湾区| 绿春县| 含山县| 商南县| 如东县| 库车县| 崇州市| 肥西县| 杭锦旗| 台南市| 英超| 临沭县| 梁平县| 长子县| 桂东县| 从江县| 阿勒泰市| 高淳县| 聊城市| 新乡县| 夏津县| 出国| 富裕县| 来安县| 伊金霍洛旗| 鄂托克旗| 湖口县| 新余市| 东丽区| 龙胜| 凤冈县| 宜州市| 增城市| 金山区| 台湾省| 兴业县|