The Number Class

This page details the properties of the Number class. To learn about what the Number class is and how you would use it, read about them in this tutorial.

Please note that this reference is elliptical because we autogenerated it. Consider it not a lesson but a reference.

Class Rules

Number.e

euler's number.

Number.pi

π—the circumference of a circle divided by its radius.

Number.random[]

a random number on the range [0, 1)

Number.random[n]

a random integer between 0 and n - 1, including 0 and n - 1.

Number.random[a, b]

a random integer between that a and b - 1; signals an error if b <= a

Instance Rules

+

adds the receiver and its argument.

-

subtracts its argument from the receiver.

*

multiplies the receiver and its argument.

/

division operator

%

modulo operator

^

power operator

<

less than operator

>

greater than operator

<=

less than or equal to operator

>=

greater than or equal to operator

.sqrt

returns the square root of the receiver.

.ln

returns the natural logarithm (base e) of the receiver.

.log[b]

the log base b of the receiver

.sin

the sine of the receiver in radians.

.cos

the cosine of the receiver in radians.

.tan

the tangent of the receiver in radians.

.sec

the secant of the receiver in radians.

.csc

the cosecant of the receiver in radians.

.cot

the cotangent of the receiver in radians.

.asin

the arcsin of the receiver; returns an angle in radians.

.acos

the arccos of the receiver; returns an angle in radians.

.atan

the arctangent of the receiver; returns an angle in radians.

.atan/[n]

a.tan/[b] is (a / b).atan; this allows us to include that a.atan/[0] is 1 without using a fake number to represent 'infinity'.

.abs

also a prefix operator

.ceil

returns the receiver rounded up.

.floor

returns the receiver rounded down.

.round

returns the receiver rounded to the nearest whole number.

.times[f]

invokes f[0]..f[receiver - 1] and returns a list of the results; signals an error if the receiver is not an integer.