Scalar

Scalar

Scalar Wrapper Class. Manages dispatching and type promotion between BigFraction, BigFloat, and Complex.

Hierarchy: Level 0: BigFraction (Rational) Level 1: BigFloat (Real/Float) Level 2: Complex (Complex)

Constructor

new Scalar(v)

Source:
Properties:
Name Type Description
value BigFraction | BigFloat | Complex

The underlying numeric value.

level number

The type promotion level (0, 1, or 2).

Parameters:
Name Type Description
v number | bigint | string | BigFraction | BigFloat | Complex | Scalar

Classes

Scalar

Methods

abs() → {Scalar}

Source:
Returns:
Type
Scalar

acos() → {Scalar}

Source:
Returns:
Type
Scalar

acosh() → {Scalar}

Source:
Returns:
Type
Scalar

add(other)

Source:
Parameters:
Name Type Description
other Scalar | any

@returns {Scalar}

asin() → {Scalar}

Source:
Returns:
Type
Scalar

asinh() → {Scalar}

Source:
Returns:
Type
Scalar

atan() → {Scalar}

Source:
Returns:
Type
Scalar

atanh() → {Scalar}

Source:
Returns:
Type
Scalar

cmp(other) → {number}

Description:
  • Compares this scalar with another value.

Source:
Parameters:
Name Type Description
other Scalar | any
Returns:

-1 if this < other, 0 if this === other, 1 if this > other.

Type
number

cos() → {Scalar}

Source:
Returns:
Type
Scalar

cosh() → {Scalar}

Source:
Returns:
Type
Scalar

div(other)

Source:
Parameters:
Name Type Description
other Scalar | any

@returns {Scalar}

equals(other) → {boolean}

Description:
  • Checks for equality with another value.

Source:
Parameters:
Name Type Description
other Scalar | any
Returns:
Type
boolean

exp() → {Scalar}

Source:
Returns:
Type
Scalar

isAlmostZero() → {boolean}

Source:
Returns:
Type
boolean

isZero() → {boolean}

Source:
Returns:
Type
boolean

log() → {Scalar}

Source:
Returns:
Type
Scalar

mul(other)

Source:
Parameters:
Name Type Description
other Scalar | any

@returns {Scalar}

neg() → {Scalar}

Source:
Returns:
Type
Scalar

operatorAdd(b)

Source:
Parameters:
Name Type Description
b Scalar | any

@returns {Scalar}

operatorDiv(b)

Source:
Parameters:
Name Type Description
b Scalar | any

@returns {Scalar}

operatorMul(b)

Source:
Parameters:
Name Type Description
b Scalar | any

@returns {Scalar}

operatorNeg() → {Scalar}

Source:
Returns:
Type
Scalar

operatorPow(b)

Source:
Parameters:
Name Type Description
b Scalar | any

@returns {Scalar}

operatorSub(b)

Source:
Parameters:
Name Type Description
b Scalar | any

@returns {Scalar}

pow(other)

Source:
Parameters:
Name Type Description
other Scalar | any

@returns {Scalar}

sin() → {Scalar}

Source:
Returns:
Type
Scalar

sinh() → {Scalar}

Source:
Returns:
Type
Scalar

sqrt() → {Scalar}

Source:
Returns:
Type
Scalar

sub(other)

Source:
Parameters:
Name Type Description
other Scalar | any

@returns {Scalar}

tan() → {Scalar}

Source:
Returns:
Type
Scalar

tanh() → {Scalar}

Source:
Returns:
Type
Scalar

toString(radixopt, precisionopt, prettyopt) → {string}

Description:
  • Converts the scalar to a string.

Source:
Parameters:
Name Type Attributes Default Description
radix number <optional>
10
precision number <optional>
-1
pretty boolean <optional>
false

pretty print

Returns:
Type
string

(static) fromString(str) → {Scalar}

Description:
  • Parses string and determines correct type/level.

Source:
Parameters:
Name Type Description
str string
Returns:
Type
Scalar

(static) getLevel(v) → {number}

Description:
  • Determine the level of a raw math object.

Source:
Parameters:
Name Type Description
v any

The value to check.

Returns:

The promotion level.

Type
number

(static) promote(v, targetLevel) → {any}

Description:
  • Promotes a raw value to the target level.

Source:
Parameters:
Name Type Description
v any

The value to promote.

targetLevel number

The target promotion level.

Returns:

The promoted value.

Type
any