- 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
推薦閱讀
- Learning Python Web Penetration Testing
- DB2 V9權威指南
- Oracle 11g從入門到精通(第2版) (軟件開發視頻大講堂)
- Oracle數據庫從入門到運維實戰
- Interactive Applications Using Matplotlib
- 小學生C++創意編程(視頻教學版)
- JavaCAPS基礎、應用與案例
- Python機器學習之金融風險管理
- 零基礎學Scratch 3.0編程
- Learning D
- Python全棧開發:基礎入門
- Kotlin進階實戰
- Android嵌入式系統程序開發(基于Cortex-A8)
- MongoDB Administrator’s Guide
- 絕密原型檔案:看看專業產品經理的原型是什么樣