- Perl 6 Deep Dive
- Andrew Shitov
- 75字
- 2021-07-03 00:05:50
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
推薦閱讀
- 工程軟件開發技術基礎
- SOA實踐
- 算法零基礎一本通(Python版)
- WebAssembly實戰
- Flink SQL與DataStream入門、進階與實戰
- Banana Pi Cookbook
- HTML5 and CSS3 Transition,Transformation,and Animation
- PHP+MySQL網站開發項目式教程
- Access 2016數據庫管
- Java Web程序設計任務教程
- Building Serverless Applications with Python
- Python時間序列預測
- OpenGL Data Visualization Cookbook
- Android開發三劍客:UML、模式與測試
- Go語言編程