- 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
推薦閱讀
- Mastering Selenium WebDriver
- 深入淺出Spring Boot 2.x
- 數據結構簡明教程(第2版)微課版
- Scratch 3游戲與人工智能編程完全自學教程
- Mastering macOS Programming
- The DevOps 2.4 Toolkit
- Visual C#.NET程序設計
- Java Web開發就該這樣學
- 小程序,巧應用:微信小程序開發實戰(第2版)
- Building Serverless Web Applications
- App Inventor少兒趣味編程動手做
- C++ System Programming Cookbook
- Arduino機器人系統設計及開發
- IPython Interactive Computing and Visualization Cookbook
- 快樂編程:青少年思維訓練