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

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
主站蜘蛛池模板: 洛扎县| 牡丹江市| 永泰县| 安国市| 宜都市| 灵武市| 苍梧县| 安福县| 宁远县| 连山| 涿州市| 永济市| 阳春市| 合水县| 舒兰市| 兴海县| 西安市| 绿春县| 扶绥县| 棋牌| 曲沃县| 青龙| 延庆县| 巫溪县| 宾川县| 乐都县| 高阳县| 辽源市| 霍邱县| 汪清县| 商城县| 乐东| 西丰县| 阳东县| 梅河口市| 峨眉山市| 邓州市| 达尔| 黑河市| 东兰县| 那曲县|