bin
Format a number as binary
Type Signatures
number | BigNumber, number | BigNumber, number | BigNumber
Parameters
| Name | Type | Description |
| value | number | BigNumber | Value to be stringified |
| wordSize | number | BigNumber | Optional word size (see `format`) |
Returns
string — The formatted value
clone
Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices
Parameters
| Name | Type | Description |
| x | * | Object to be cloned |
Returns
* — A clone of object x
Examples
clone(3.5)
clone(2 - 4i)
clone(45 deg)
clone([1
2; 3
hasNumericValue
Test whether a value is an numeric value.
Syntax
hasNumericValue(x)
Parameters
| Name | Type | Description |
| x | * | Value to be tested |
Returns
boolean — Returns true when `x` is a `number`, `BigNumber`,
Examples
hasNumericValue(2)
hasNumericValue("2")
isNumeric("2")
hasNumericValue(0)
hasNumericValue(bignumber(500))
hex
Format a number as hexadecimal
Type Signatures
number | BigNumber, number | BigNumber, number | BigNumber
Parameters
| Name | Type | Description |
| value | number | BigNumber | Value to be stringified |
| wordSize | number | BigNumber | Optional word size (see `format`) |
Returns
string — The formatted value
isBounded
Test whether a value or its entries are bounded.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is bounded.
Examples
isBounded(Infinity)
isBounded(bigint(3))
isBounded([3
-Infinity
-3
isFinite
Test whether a value is finite, elementwise on collections.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean | Array | Matrix —
Examples
isFinite(Infinity)
isFinite(bigint(3))
isFinite([3
-Infinity
-3
isInteger
Test whether a value is an integer number.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Fraction | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` contains a numeric, integer value.
Examples
isInteger(2)
isInteger(3.5)
isInteger([3
0.5
-2
isNaN
Test whether a value is NaN (not a number)
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is NaN.
Examples
isNaN(2)
isNaN(0 / 0)
isNaN(NaN)
isNaN(Infinity)
isNegative
Test whether a value is negative: smaller than zero.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is larger than zero.
Examples
isNegative(2)
isNegative(0)
isNegative(-4)
isNegative([3
0.5
isNumeric
Test whether a value is a numeric value.
Parameters
| Name | Type | Description |
| x | * | Value to be tested |
Returns
boolean — Returns true when `x` is a `number`, `BigNumber`,
Examples
isNumeric(2)
isNumeric("2")
hasNumericValue("2")
isNumeric(0)
isNumeric(bignumber(500))
isPositive
Test whether a value is positive: larger than zero.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is larger than zero.
Examples
isPositive(2)
isPositive(0)
isPositive(-4)
isPositive([3
0.5
isPrime
Test whether a value is prime: has no divisors other than itself and one.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is larger than zero.
Examples
isPrime(3)
isPrime(-2)
isPrime([2
17
100
isZero
Test whether a value is zero.
Parameters
| Name | Type | Description |
| x | number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix | Value to be tested |
Returns
boolean — Returns true when `x` is zero.
Examples
isZero(2)
isZero(0)
isZero(-4)
isZero([3
0
numeric
Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.
Parameters
| Name | Type | Description |
| value | string | number | BigNumber | bigint | Fraction | |
| outputType | string | |
Returns
number | BigNumber | bigint | Fraction —
Examples
numeric("4")
numeric("4
number")
numeric("4
bigint")
oct
Format a number as octal
Type Signatures
number | BigNumber, number | BigNumber, number | BigNumber
Parameters
| Name | Type | Description |
| value | number | BigNumber | Value to be stringified |
| wordSize | number | BigNumber | Optional word size (see `format`) |
Returns
string — The formatted value
print
Interpolate values into a string template.
Syntax
print(template | values) | print(template
Parameters
| Name | Type | Description |
| template | string | A string containing variable placeholders. |
| values | Object | Array | Matrix | An object or array containing variables |
| options | number | Object | Formatting options, |
Returns
string — Interpolated string
Examples
print("Lucy is $age years old
{age: 5})
print("The value of pi is $pi
{pi: pi}
3)
typeOf
Get the type of a variable.
Parameters
| Name | Type | Description |
| x | * | The variable for which to test the type. |
Returns
string — Returns the name of the type. Primitive types are lower case,
Examples
typeOf(3.5)
typeOf(2 - 4i)
typeOf(45 deg)
typeOf("hello world")