- 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
推薦閱讀
- 復雜軟件設計之道:領域驅動設計全面解析與實戰
- C程序設計簡明教程(第二版)
- Java高手真經(高級編程卷):Java Web高級開發技術
- Rake Task Management Essentials
- 機械工程師Python編程:入門、實戰與進階
- Effective Python Penetration Testing
- 微信小程序開發解析
- Serverless架構
- KnockoutJS Starter
- UML 基礎與 Rose 建模案例(第3版)
- 西門子S7-200 SMART PLC編程從入門到實踐
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- STM8實戰
- Beginning C# 7 Hands-On:The Core Language
- RESTful Web API Design with Node.js(Second Edition)