feat: add isInfinity and isInteger methods to Num class

Implements two new methods on the Num class: isInfinity checks if a number is positive or negative infinity using isinf(), and isInteger checks if a number has no fractional component, returning false for NaN and infinity. Includes C primitives, documentation, and test files.
This commit is contained in:
Bob Nystrom
2015-09-30 15:41:43 +00:00
parent b3086333f0
commit af90291f6f
4 changed files with 44 additions and 0 deletions
+16
View File
@@ -60,6 +60,22 @@ Rounds the number down to the nearest integer.
1.5.floor // 1
(-3.2).floor // -4
### **isInfinity**
Whether the number is positive or negative infinity or not.
:::wren
99999.isInfinity // false
(1/0).isInfinity // true
### **isInteger**
Whether the number is an integer or has some fractional component.
:::wren
2.isInteger // true
2.3.isInteger // false
### **isNan**
Whether the number is [not a number](http://en.wikipedia.org/wiki/NaN). This is