- 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
推薦閱讀
- Embedded Linux Projects Using Yocto Project Cookbook
- Deploying Node.js
- VMware View Security Essentials
- OpenCV實例精解
- 物聯網系統開發:從0到1構建IoT平臺(第2版)
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- jQuery開發基礎教程
- 名師講壇:Spring實戰開發(Redis+SpringDataJPA+SpringMVC+SpringSecurity)
- Active Directory with PowerShell
- 深度學習:Java語言實現
- 持續輕量級Java EE開發:編寫可測試的代碼
- 智能手機APP UI設計與應用任務教程
- Learning YARN
- 深入淺出Go語言編程
- Developing SSRS Reports for Dynamics AX