-
Notifications
You must be signed in to change notification settings - Fork 4
number
A number may be an int, a fraction, or a float.
int values share some methods with other numbers, but also have their own.
(num? x) -> returns true if x is a number
(int? x) -> returns true if x is an integer
(nint? x) -> returns true if x is a number, but not an integer
(num? 1) -> true
(num? 1/2) -> true
(num? 2.3) -> true
(int? 1) -> true
(int? 2/1) -> true
(int? 2.0) -> true
(int? 1/2) -> false
(int? 2.3) -> false
(nint? 1) -> false
(nint? 1/2) -> true
(nint? 2.3) -> true
x.type -> number
x.zero? -> returns true if x is 0, false otherwise.
x.pos? -> returns true if x is > 0, false otherwise.
x.neg? -> returns true if x is < 0, false otherwise.
x.abs -> returns the absolute value of x.
x.to-bool -> returns false if x is 0, true otherwise.
x.to-text -> returns a textual version of the number.
x.floor -> closest int less than x
x.ceil -> closest int greater than x
x.round -> round x to the nearest int
x.truncate -> closest int closer to 0 than x
x.type -> int
x.inc -> x + 1
x.dec -> x - 1
x.even? -> true if x is even, false if odd
x.odd? -> true if x is odd, false if even