Number
Module | ejs |
Namespace | intrinsic |
Definition | final class Number |
Inheritance | Number ![]() |
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
Qualifiers | Property | Type | Description |
---|---|---|---|
public static const | MaxValue | Number | Return the maximim value this number type can assume. |
public static const | MinValue | Number | Return the minimum value this number type can assume. |
Number Methods
Qualifiers | Method |
---|---|
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
Returns the absolute value of a number (which is equal to its magnitude).
- Returns
- The absolute value.
- Specified
- Ejs-11.
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.
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.
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)
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)
Returns true if the number is not Infinity or NegativeInfinity.
- Returns
- A boolean.
- Specified
- Ejs-11.
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.
Returns the greater of the number or the argument.
- Parameters
other: Number The number to compare to
- Returns
- A number.
- Specified
- Ejs-11.
Returns the lessor of the number or the argument.
- Parameters
other: Number The number to compare to
- Returns
- A number.
- Specified
- Ejs-11.
Number constructor.
- Parameters
Returns a number which is equal to this number raised to the power of the argument.
- Parameters
- Returns
- A number.
- Specified
- Ejs-11.
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.
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.
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.