Skip to main content

Numeric

Index

Interfaces

Add

Add<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

+

  • +(left, right): Output
  • Addition operator

    @example
    type T = ...;
    const TNumeric: Numeric.Add<T> = ...;
    const result = TNumeric['+'](left, right);// represents (left + right)

CheckedAdd

CheckedAdd<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

+?

  • +?(left, right): Option<Output>
  • Addition operator that returns None instead of wrapping around on overflow.

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedAdd<T> = ...;
    const result = TNumeric['+?'](left, right);// represents (left + right)

CheckedDivide

CheckedDivide<Base, Divider, Output>:

Type parameters

  • Base
  • Divider = Base
  • Output = Base

/?

  • /?(left, right): Option<Output>
  • Division operator

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedDivide<T> = ...;
    const result = Numeric['/?'](left, right);// represents (left / right)

CheckedMultiply

CheckedMultiply<Base, Multiplier, Output>:

Type parameters

  • Base
  • Multiplier = Base
  • Output = Base

*?

  • *?(base, multiplier): Option<Output>
  • Multiplication operator that returns None instead of wrapping around on overflow.

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedMultiply<T> = ...;
    const result = Numeric['*?'](left, right);// represents (left * right)

CheckedPower

CheckedPower<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

**?

  • **?(left, right): Option<Output>
  • Power operator that returns None instead of wrapping around on overflow.

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedPower<T> = ...;
    const result = TNumeric['**?'](left, right);// represents (left ** right)

CheckedRemainder

CheckedRemainder<Base, Divider, Output>:

Type parameters

  • Base
  • Divider = Base
  • Output = Base

%?

  • %?(left, right): Option<Output>
  • Remainder operator

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedRemainder<T> = ...;
    const result = Numeric['%?'](left, right);// represents (left % right)

CheckedSubtract

CheckedSubtract<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

-?

  • -?(left, right): Option<Output>
  • Subtraction operator that returns None instead of wrapping around on overflow.

    @example
    type T = ...;
    const TNumeric: Numeric.CheckedSubtract<T> = ...;
    const result = TNumeric['-?'](left, right);// represents (left - right)

Divide

Divide<Base, Divider, Output>:

Type parameters

  • Base
  • Divider = Base
  • Output = Base

/

  • /(base, divider): Output
  • Division operator

    @example
    type T = ...;
    const TNumeric: Numeric.Divide<T> = ...;
    const result = Numeric['/'](left, right);// represents (left / right)

Integral

Integral<T>:

Integral type


Type parameters

  • T

constructor

constructor:

inherited-

  • -(left, right): T
  • Subtraction operator

    @example
    type T = ...;
    const TNumeric: Numeric.Subtract<T> = ...;
    const result = Numeric['-'](left, right);// represents (left - right)

inherited*

  • *(left, right): T
  • Multiplication operator

    @example
    type T = ...;
    const TNumeric: Numeric.Multiply<T> = ...;
    const result = Numeric['*'](left, right);// represents (left * right)

inherited/

  • /(base, divider): T
  • Division operator

    @example
    type T = ...;
    const TNumeric: Numeric.Divide<T> = ...;
    const result = Numeric['/'](left, right);// represents (left / right)

/%

  • /%(this, base, divider): [quot: T, mod: T]
  • Quotient/Modulo operator

    @example
    type T = ...;
    const TNumeric: Numeric.Integral<T> = ...;
    const result = Numeric['/%'](left, right);// represents [ left / right, left % right ]

inherited%

  • %(left, right): T
  • Remainder operator

    @example
    type T = ...;
    const TNumeric: Numeric.Remainder<T> = ...;
    const result = Numeric['%'](left, right);// represents (left % right)

inherited+

  • +(left, right): T
  • Addition operator

    @example
    type T = ...;
    const TNumeric: Numeric.Add<T> = ...;
    const result = TNumeric['+'](left, right);// represents (left + right)

inheritedabs

  • abs(this, value): T
  • Absolute value. It should satisfy Numeric['*'](Numeric.abs(x), Numeric.sign(x)) == x

    @example
    type T = ...;
    const TSigned: Numeric.Signed<T> = ...;
    const result = TSigned.abs(value);// absolute value of (value)

inheritedasInt

  • asInt(this, self): Int
  • Converts the given value to a Int.

    @example
    const SomeType: AsInt<T>;
    const value: T;
    SomeType.asInt(value); // Int(...)

inheritedfromInt

  • fromInt(this, value): T

inheritedisNegative

  • isNegative(this, self): boolean
  • Returns true if the number is negative and false if the number is zero or positive.

    @example
    Number.isPositive(-1);// true
    Number.isPositive(0);// false
    Number.isPositive(1);// false

inheritedisOne

  • isOne(this, self): boolean
  • Returns true if self is equal to the multiplicative identity.

    @example
    Number.isOne(1); // true
    Number.isOne(0); // false

inheritedisPositive

  • isPositive(this, self): boolean
  • Returns true if the number is positive and false if the number is zero or negative.

    @example
    Number.isPositive(-1);// false
    Number.isPositive(0);// false
    Number.isPositive(1);// true

inheritedisZero

  • isZero(this, self): boolean
  • Returns true if self is equal to the additive identity.

    @example
    Number.isZero(0); // true
    Number.isZero(1); // false

inheritednegate

  • negate(this, self): T
  • Negates the given value.

    @example
    Number.negate(5); // -5
    Number.negate(Number.negate(5)); // 5

inheritedone

  • one(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.one(); // 1

inheritedsign

  • sign(this, value): T
  • Sign of a number. It should satisfy TSigned['*'](TSigned.abs(x), TSigned.sign(x)) == x

    @example
    Number.sign(-2.5);// -1
    Number.sign(0);// 0
    Number.sign(2.5);// 1

inheritedzero

  • zero(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.zero(); // 0

IntegralParameters

IntegralParameters<T>:

Type parameters

  • T

inheritedcompare

compare: (left, right) => Ordering

optionalinherited-

  • -(left, right): T
  • Subtraction operator

    @example
    type T = ...;
    const TNumeric: Numeric.Subtract<T> = ...;
    const result = Numeric['-'](left, right);// represents (left - right)

inherited*

  • *(left, right): T
  • Multiplication operator

    @example
    type T = ...;
    const TNumeric: Numeric.Multiply<T> = ...;
    const result = Numeric['*'](left, right);// represents (left * right)

inherited/

  • /(base, divider): T
  • Division operator

    @example
    type T = ...;
    const TNumeric: Numeric.Divide<T> = ...;
    const result = Numeric['/'](left, right);// represents (left / right)

inherited%

  • %(left, right): T
  • Remainder operator

    @example
    type T = ...;
    const TNumeric: Numeric.Remainder<T> = ...;
    const result = Numeric['%'](left, right);// represents (left % right)

inherited+

  • +(left, right): T
  • Addition operator

    @example
    type T = ...;
    const TNumeric: Numeric.Add<T> = ...;
    const result = TNumeric['+'](left, right);// represents (left + right)

optionalinheritedabs

  • abs(this, value): T
  • Absolute value. It should satisfy Numeric['*'](Numeric.abs(x), Numeric.sign(x)) == x

    @example
    type T = ...;
    const TSigned: Numeric.Signed<T> = ...;
    const result = TSigned.abs(value);// absolute value of (value)

inheritedasInt

  • asInt(this, self): Int
  • Converts the given value to a Int.

    @example
    const SomeType: AsInt<T>;
    const value: T;
    SomeType.asInt(value); // Int(...)

inheritedfromInt

  • fromInt(this, value): T

optionalinheritedisNegative

  • isNegative(this, self): boolean
  • Returns true if the number is negative and false if the number is zero or positive.

    @example
    Number.isPositive(-1);// true
    Number.isPositive(0);// false
    Number.isPositive(1);// false

optionalinheritedisOne

  • isOne(this, self): boolean
  • Returns true if self is equal to the multiplicative identity.

    @example
    Number.isOne(1); // true
    Number.isOne(0); // false

optionalinheritedisPositive

  • isPositive(this, self): boolean
  • Returns true if the number is positive and false if the number is zero or negative.

    @example
    Number.isPositive(-1);// false
    Number.isPositive(0);// false
    Number.isPositive(1);// true

optionalinheritedisZero

  • isZero(this, self): boolean
  • Returns true if self is equal to the additive identity.

    @example
    Number.isZero(0); // true
    Number.isZero(1); // false

optionalinheritednegate

  • negate(this, self): T
  • Negates the given value.

    @example
    Number.negate(5); // -5
    Number.negate(Number.negate(5)); // 5

optionalinheritedone

  • one(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.one(); // 1

optionalinheritedsign

  • sign(this, value): T
  • Sign of a number. It should satisfy TSigned['*'](TSigned.abs(x), TSigned.sign(x)) == x

    @example
    Number.sign(-2.5);// -1
    Number.sign(0);// 0
    Number.sign(2.5);// 1

optionalinheritedzero

  • zero(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.zero(); // 0

Multiply

Multiply<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

*

  • *(left, right): Output
  • Multiplication operator

    @example
    type T = ...;
    const TNumeric: Numeric.Multiply<T> = ...;
    const result = Numeric['*'](left, right);// represents (left * right)

Negate

Negate<Self, Output>:

Type parameters

  • Self
  • Output = Self

negate

  • negate(this, self): Output
  • Negates the given value.

    @example
    Number.negate(5); // -5
    Number.negate(Number.negate(5)); // 5

Numeric

Numeric<T>:

Type parameters

  • T

constructor

constructor:

inherited-

  • -(left, right): T
  • Subtraction operator

    @example
    type T = ...;
    const TNumeric: Numeric.Subtract<T> = ...;
    const result = Numeric['-'](left, right);// represents (left - right)

inherited*

  • *(left, right): T
  • Multiplication operator

    @example
    type T = ...;
    const TNumeric: Numeric.Multiply<T> = ...;
    const result = Numeric['*'](left, right);// represents (left * right)

inherited+

  • +(left, right): T
  • Addition operator

    @example
    type T = ...;
    const TNumeric: Numeric.Add<T> = ...;
    const result = TNumeric['+'](left, right);// represents (left + right)

inheritedabs

  • abs(this, value): T
  • Absolute value. It should satisfy Numeric['*'](Numeric.abs(x), Numeric.sign(x)) == x

    @example
    type T = ...;
    const TSigned: Numeric.Signed<T> = ...;
    const result = TSigned.abs(value);// absolute value of (value)

inheritedasInt

  • asInt(this, self): Int
  • Converts the given value to a Int.

    @example
    const SomeType: AsInt<T>;
    const value: T;
    SomeType.asInt(value); // Int(...)

fromInt

  • fromInt(this, value): T

inheritedisNegative

  • isNegative(this, self): boolean
  • Returns true if the number is negative and false if the number is zero or positive.

    @example
    Number.isPositive(-1);// true
    Number.isPositive(0);// false
    Number.isPositive(1);// false

inheritedisOne

  • isOne(this, self): boolean
  • Returns true if self is equal to the multiplicative identity.

    @example
    Number.isOne(1); // true
    Number.isOne(0); // false

inheritedisPositive

  • isPositive(this, self): boolean
  • Returns true if the number is positive and false if the number is zero or negative.

    @example
    Number.isPositive(-1);// false
    Number.isPositive(0);// false
    Number.isPositive(1);// true

inheritedisZero

  • isZero(this, self): boolean
  • Returns true if self is equal to the additive identity.

    @example
    Number.isZero(0); // true
    Number.isZero(1); // false

inheritednegate

  • negate(this, self): T
  • Negates the given value.

    @example
    Number.negate(5); // -5
    Number.negate(Number.negate(5)); // 5

inheritedone

  • one(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.one(); // 1

inheritedsign

  • sign(this, value): T
  • Sign of a number. It should satisfy TSigned['*'](TSigned.abs(x), TSigned.sign(x)) == x

    @example
    Number.sign(-2.5);// -1
    Number.sign(0);// 0
    Number.sign(2.5);// 1

inheritedzero

  • zero(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.zero(); // 0

NumericParameters

NumericParameters<T>:

Type parameters

  • T

inheritedcompare

compare: (left, right) => Ordering

optionalinherited-

  • -(left, right): T
  • Subtraction operator

    @example
    type T = ...;
    const TNumeric: Numeric.Subtract<T> = ...;
    const result = Numeric['-'](left, right);// represents (left - right)

inherited*

  • *(left, right): T
  • Multiplication operator

    @example
    type T = ...;
    const TNumeric: Numeric.Multiply<T> = ...;
    const result = Numeric['*'](left, right);// represents (left * right)

inherited+

  • +(left, right): T
  • Addition operator

    @example
    type T = ...;
    const TNumeric: Numeric.Add<T> = ...;
    const result = TNumeric['+'](left, right);// represents (left + right)

optionalinheritedabs

  • abs(this, value): T
  • Absolute value. It should satisfy Numeric['*'](Numeric.abs(x), Numeric.sign(x)) == x

    @example
    type T = ...;
    const TSigned: Numeric.Signed<T> = ...;
    const result = TSigned.abs(value);// absolute value of (value)

inheritedasInt

  • asInt(this, self): Int
  • Converts the given value to a Int.

    @example
    const SomeType: AsInt<T>;
    const value: T;
    SomeType.asInt(value); // Int(...)

inheritedfromInt

  • fromInt(this, value): T

optionalinheritedisNegative

  • isNegative(this, self): boolean
  • Returns true if the number is negative and false if the number is zero or positive.

    @example
    Number.isPositive(-1);// true
    Number.isPositive(0);// false
    Number.isPositive(1);// false

optionalinheritedisOne

  • isOne(this, self): boolean
  • Returns true if self is equal to the multiplicative identity.

    @example
    Number.isOne(1); // true
    Number.isOne(0); // false

optionalinheritedisPositive

  • isPositive(this, self): boolean
  • Returns true if the number is positive and false if the number is zero or negative.

    @example
    Number.isPositive(-1);// false
    Number.isPositive(0);// false
    Number.isPositive(1);// true

optionalinheritedisZero

  • isZero(this, self): boolean
  • Returns true if self is equal to the additive identity.

    @example
    Number.isZero(0); // true
    Number.isZero(1); // false

optionalinheritednegate

  • negate(this, self): T
  • Negates the given value.

    @example
    Number.negate(5); // -5
    Number.negate(Number.negate(5)); // 5

optionalinheritedone

  • one(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.one(); // 1

optionalinheritedsign

  • sign(this, value): T
  • Sign of a number. It should satisfy TSigned['*'](TSigned.abs(x), TSigned.sign(x)) == x

    @example
    Number.sign(-2.5);// -1
    Number.sign(0);// 0
    Number.sign(2.5);// 1

optionalinheritedzero

  • zero(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.zero(); // 0

One

One<T>:

Type parameters

  • T

isOne

  • isOne(this, self): boolean
  • Returns true if self is equal to the multiplicative identity.

    @example
    Number.isOne(1); // true
    Number.isOne(0); // false

one

  • one(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.one(); // 1

Power

Power<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

**

  • **(left, right): Output
  • Power operator

    @example
    type T = ...;
    const TNumeric: Numeric.Power<T> = ...;
    const result = Numeric['**'](left, right);// represents (left ** right)

Remainder

Remainder<Base, Divider, Output>:

Type parameters

  • Base
  • Divider = Base
  • Output = Base

%

  • %(left, right): Output
  • Remainder operator

    @example
    type T = ...;
    const TNumeric: Numeric.Remainder<T> = ...;
    const result = Numeric['%'](left, right);// represents (left % right)

Signed

Signed<T>:

Type parameters

  • T

abs

  • abs(this, value): T
  • Absolute value. It should satisfy Numeric['*'](Numeric.abs(x), Numeric.sign(x)) == x

    @example
    type T = ...;
    const TSigned: Numeric.Signed<T> = ...;
    const result = TSigned.abs(value);// absolute value of (value)

isNegative

  • isNegative(this, self): boolean
  • Returns true if the number is negative and false if the number is zero or positive.

    @example
    Number.isPositive(-1);// true
    Number.isPositive(0);// false
    Number.isPositive(1);// false

isPositive

  • isPositive(this, self): boolean
  • Returns true if the number is positive and false if the number is zero or negative.

    @example
    Number.isPositive(-1);// false
    Number.isPositive(0);// false
    Number.isPositive(1);// true

sign

  • sign(this, value): T
  • Sign of a number. It should satisfy TSigned['*'](TSigned.abs(x), TSigned.sign(x)) == x

    @example
    Number.sign(-2.5);// -1
    Number.sign(0);// 0
    Number.sign(2.5);// 1

Subtract

Subtract<Left, Right, Output>:

Type parameters

  • Left
  • Right = Left
  • Output = Left

-

  • -(left, right): Output
  • Subtraction operator

    @example
    type T = ...;
    const TNumeric: Numeric.Subtract<T> = ...;
    const result = Numeric['-'](left, right);// represents (left - right)

Zero

Zero<T>:

Type parameters

  • T

isZero

  • isZero(this, self): boolean
  • Returns true if self is equal to the additive identity.

    @example
    Number.isZero(0); // true
    Number.isZero(1); // false

zero

  • zero(this): T
  • Returns the additive identity element of T, 0.

    @example
    Number.zero(); // 0

Functions

Integral

Numeric