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

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
主站蜘蛛池模板: 平安县| 高平市| 宝丰县| 宁陵县| 图木舒克市| 叶城县| 台前县| 囊谦县| 新绛县| 龙游县| 芜湖县| 太湖县| 溧水县| 竹北市| 陇西县| 罗定市| 许昌市| 芦山县| 射洪县| 垫江县| 许昌市| 宁晋县| 岑溪市| 济阳县| 潼关县| 樟树市| 馆陶县| 潼南县| 客服| 雅安市| 花莲县| 白玉县| 辰溪县| 林口县| 达州市| 辽宁省| 保靖县| 台南县| 盘山县| 普宁市| 久治县|