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
+11
View File
@@ -0,0 +1,11 @@
System.print(123.isInteger) // expect: true
System.print(123.0.isInteger) // expect: true
System.print(0.isInteger) // expect: true
System.print(1.0000001.isInteger) // expect: false
System.print((-2.3).isInteger) // expect: false
// NaN is not an integer.
System.print((0/0).isInteger) // expect: false
// Infinity is not an integer.
System.print((1/0).isInteger) // expect: false