The number module

The number module provides a set of functions for working with numbers. It is the metatable for all numbers.

Fields

inf: number

The infinity value as defined by IEEE 754.

negInf: number

The negative infinity value as defined by IEEE 754.

nan: number

The not-a-number value as defined by IEEE 754.

Free functions

parse(s: string, radix: number = 10): number

Parse a string into a number with a given radix. The radix must be between 2 and 36.

Member functions

char(self): string

Convert a number to its character representation.

stringWithRadix(self, radix: number): string

Convert a number to a string with a given radix. The radix must be between 2 and 36.

Metamethods

__cmp__(self, other: number): number

Compare a number to another number.

__div__(self, other: number): number

Divide a number by another number.

__eq__(self, other: number): boolean

Check if a number is equal to another number.

__inclRange__(self, other: number): number

Create a range from a number to another number (inclusive).

__minus__(self, other: number): number

Subtract a number from another number.

__mod__(self, other: number): number

Calculate the modulo of a number and another number.

__neg__(self): number

Negate a number.

__range__(self, other: number): number

Create a range from a number to another number (exclusive).

__times__(self, other: number): number

Multiply a number by another number.