Number

Moduleejs
Namespaceintrinsic
Definitionfinal class Number
InheritanceNumber inherit Object

The Number type is used by all numeric values in Ejscript.

Depending on how Ejscript is configured, the underlying number representation may be based on either an int, long, int64 or double data type. If the underlying type is integral (not double) then some of these routines will be mapped onto.


Properties

QualifiersPropertyTypeDescription
public static const MaxValueNumberReturn the maximim value this number type can assume.
public static const MinValueNumberReturn the minimum value this number type can assume.

Number Methods

QualifiersMethod
public get abs(): Number
 Returns the absolute value of a number (which is equal to its magnitude).
public get ceil(): Number
 The ceil function computes the smallest integral number that is greater or equal to the number value.
public get floor(): Number
 Compuete the largest integral number that is smaller than the number value.
iterator override get(deep: Boolean): Iterator
 Return an iterator that can be used to iterate a given number of times.
iterator override getValues(deep: Boolean): Iterator
 Return an iterator that can be used to iterate a given number of times.
public get isFinite(): Boolean
 Returns true if the number is not Infinity or NegativeInfinity.
public get isNaN(): Boolean
 Returns true if the number is equal to the NaN value.
public max(other: Number): Number
 Returns the greater of the number or the argument.
public min(other: Number): Number
 Returns the lessor of the number or the argument.
Number(value: Array)
 Number constructor.
public power(power: Number): Number
 Returns a number which is equal to this number raised to the power of the argument.
public get round(): Number
 Compute the integral number that is closest to this number.
public toFixed(fractionDigits: Number): String
 Returns the number formatted as a string with the specified number of digits after the decimal point.
public toPrecision(numDigits: Number): String
 Returns the number formatted as a string in either fixed or exponential notation with argument number of digits.

Method Detail

get public abs(): Number

Returns the absolute value of a number (which is equal to its magnitude).

Returns
The absolute value.
Specified
Ejs-11.

get public ceil(): Number

The ceil function computes the smallest integral number that is greater or equal to the number value.

Returns
A number rounded up to the next integral value.
Specified
Ejs-11.

get public floor(): Number

Compuete the largest integral number that is smaller than the number value.

Returns
A number rounded down to the closest integral value.
Specified
Ejs-11.

override iterator get(deep: Boolean): Iterator

Return an iterator that can be used to iterate a given number of times.

Description
This is used in for/in statements.
Parameters
deep: Boolean Ignored [default: false]
Returns
An iterator.
Specified
Ejs-11.
Example
for (i in 5) print(i)

override iterator getValues(deep: Boolean): Iterator

Return an iterator that can be used to iterate a given number of times.

Description
This is used in for/each statements.
Parameters
deep: Boolean Ignored [default: false]
Returns
An iterator.
Specified
Ejs-11.
Example
for each (i in 5) print(i)

get public isFinite(): Boolean

Returns true if the number is not Infinity or NegativeInfinity.

Returns
A boolean.
Specified
Ejs-11.

get public isNaN(): Boolean

Returns true if the number is equal to the NaN value.

Description
If the numeric type is integral, this will always return false.
Returns
A boolean.
Specified
Ejs-11.

public max(other: Number): Number

Returns the greater of the number or the argument.

Parameters
other: Number The number to compare to
Returns
A number.
Specified
Ejs-11.

public min(other: Number): Number

Returns the lessor of the number or the argument.

Parameters
other: Number The number to compare to
Returns
A number.
Specified
Ejs-11.

Number(value: Array)

Number constructor.

Parameters

public power(power: Number): Number

Returns a number which is equal to this number raised to the power of the argument.

Parameters
Returns
A number.
Specified
Ejs-11.

get public round(): Number

Compute the integral number that is closest to this number.

Description
Returns the closest integer value of this number closest to the number. ie. round up or down to the closest integer.
Returns
A integral number.
Specified
Ejs-11.

public toFixed(fractionDigits: Number): String

Returns the number formatted as a string with the specified number of digits after the decimal point.

Parameters
fractionDigits: Number The number of digits in the fraction.
Returns
A string.

public toPrecision(numDigits: Number): String

Returns the number formatted as a string in either fixed or exponential notation with argument number of digits.

Parameters
numDigits: Number The number of digits in the result [default: SOME_DEFAULT]
Returns
A string.
Specified
Ejs-11.