Home Reference Source
import BigDecimal from 'konpeito/src/math/core/BigDecimal.js'
public class | source

BigDecimal

Extends:

KonpeitoIntegerKonpeitoFloat → BigDecimal

Arbitrary-precision floating-point number class (immutable).

Static Member Summary

Static Public Members
public static get

E, Napier's constant.

public static get

0.5

public static get

0.5 * PI.

public static get

log_e(10)

public static get

log_e(2)

public static get

log_10(e)

public static get

log_2(e)

public static get

-1

public static get

Negative Infinity.

public static get

Not a Number.

public static get

1

public static get

PI

public static get

Positive infinity.

public static get

0.25 * PI.

public static get

sqrt(0.5)

public static get

sqrt(2)

public static get

10

public static get

2

public static get

2 * PI.

public static get

0

Static Method Summary

Static Public Methods
public static

Create an arbitrary-precision floating-point number.

public static

Return default MathContext class.

public static

Pop default the MathContext.

public static

Push default the MathContext.

public static

rand(random: Random): BigDecimal

Create random values with uniform random numbers.

public static

randn(random: Random): BigDecimal

Create random values with normal distribution.

public static

Set default the MathContext.

public static

Convert number to BigDecimal type.

Constructor Summary

Public Constructor
public

Create an arbitrary-precision floating-point number.

Member Summary

Public Members
public get

boolean value.

public get

64-bit floating point.

public get

32-bit floating point.

public get

32-bit integer value.

public get

32-bit integer value.

Method Summary

Public Methods
public

Absolute value.

public

Arc cosine function.

public

Inverse hyperbolic cosine function.

public

Inverse cotangent function.

public

Inverse hyperbolic cotangent function.

public

Inverse cosecant function.

public

Inverse hyperbolic cosecant function.

public

Add.

public

Logical AND.

public

Reverse secant function.

public

Inverse hyperbolic secant function.

public

Arc sine function.

public

Inverse hyperbolic sine function.

public

Atan (arc tangent) function.

public

Atan (arc tangent) function.

public

Inverse hyperbolic tangent function.

public

Cube root.

public

Ceil.

public

Clip number within range.

public

Deep copy.

public

Compare values.

public

Cosine function.

public

Hyperbolic cosine function.

public

Cotangent function.

public

Hyperbolic cotangent function.

public

Cosecant function.

public

Hyperbolic cosecant function.

public

Divide.

public

Divide.

public

Divide and remainder.

public

Divide not calculated to the decimal point.

public

Equals.

public

Numeric type match.

public

Exponential function.

public

e^x - 1

public

Extended Euclidean algorithm.

public

Factorization.

public

Factorial function, x!.

public

To integer rounded down to the nearest.

public

Floor.

public

Fraction.

public

Euclidean algorithm.

public

Inverse number of this value.

public

Return true if the value is finite number.

public

this === Infinity or -Infinity

public

Return true if the value is integer.

public

this === NaN

public

this < 0

public

this === -Infinity

public

this >= 0

public

this === 1

public

this > 0

public

this === Infinity

public

Return true if the value is prime number.

public

Return true if the value is prime number by Miller-Labin prime number determination method.

public

this === 0

public

Least common multiple.

public

Logarithmic function.

public

log_10(x)

public

ln(1 + x)

public

log_2(x)

public

Logit function.

public

Maximum number.

public

Minimum number.

public

Modulo, positive remainder of division.

public

Modular multiplicative inverse.

public

Modular exponentiation.

public

Move the decimal point to the left.

public

Move the decimal point to the right.

public

Multiply.

public

Multiply.

public

this * -1

public

Next prime.

public

Logical Not.

public

Logical OR.

public

this * 1

public

Power function.

public

Precision.

public

Remainder of division.

public

Remainder of division.

public

Round with specified settings.

public

Reciprocal square root.

public

The scale of this BigDecimal.

public

Multiply a multiple of ten.

public

Secant function.

public

Hyperbolic secant function.

public

Change the scale.

public

this << n

  • Calculated as an integer.
public

The positive or negative sign of this number.

public

The positive or negative sign of this number.

public

Sine function.

public

Normalized sinc function.

public

Hyperbolic sine function.

public

Square root.

public

Square.

public

Remove the 0 to the right of the numbers and normalize the scale.

public

Subtract.

public

Subtract.

public

Tangent function.

public

Hyperbolic tangent function.

public

return BigDecimal.

public

return BigInteger.

public

return Complex.

public

Convert to string usding technical notation.

public

return Fraction.

public

Convert to JSON.

public

return Matrix.

public

Convert to string without exponential notation.

public

Convert to string using scientific notation.

public

Convert to string.

public

To integer rounded down to the nearest.

public

The smallest value that can be represented with the set precision.

public

An integer with the exponent part removed.

public

Logical Exclusive-OR.

Private Methods
private

Return string of this number without sign.

Inherited Summary

From class KonpeitoInteger
public static get

-1

public static get

Negative Infinity.

public static get

Not a Number.

public static get

1

public static get

Positive infinity.

public static get

10

public static get

2

public static get

0

public static

create(number: any): KonpeitoInteger

Create an entity object of this class.

public static

valueOf(number: any): KonpeitoInteger

Create number.

public get

boolean value.

public get

floating point.

public get

integer value.

public

Absolute value.

public

add(number: any): KonpeitoInteger

Add.

public

and(number: any): KonpeitoInteger

Logical AND.

public

Ceil.

public

Deep copy.

public

compareTo(number: any): number

Compare values.

public

div(number: any): KonpeitoInteger

Divide.

public

divide(number: any): KonpeitoInteger

Divide.

public

equals(number: any): boolean

Equals.

public

extgcd(number: any): KonpeitoInteger[]

Extended Euclidean algorithm.

public

Factorization.

public

Factorial function, x!.

public

To integer rounded down to the nearest.

public

Floor.

public

Fraction.

public

gcd(number: any): KonpeitoInteger

Euclidean algorithm.

public

Inverse number of this value.

public

Return true if the value is finite number.

public

this === Infinity or -Infinity

public

this === NaN

public

this < 0

public

this === -Infinity

public

this >= 0

public

this === 1

public

this > 0

public

this === Infinity

public

Return true if the value is prime number.

public

isProbablePrime(certainty: any): boolean

Return true if the value is prime number by Miller-Labin prime number determination method.

public

this === 0

public

lcm(number: any): KonpeitoInteger

Least common multiple.

public

mod(number: any): KonpeitoInteger

Modulo, positive rem of division.

public

Modular multiplicative inverse.

public

modPow(exponent: any, m: any): KonpeitoInteger

Modular exponentiation.

public

mul(number: any): KonpeitoInteger

Multiply.

public

multiply(number: any): KonpeitoInteger

Multiply.

public

this * -1

public

nextProbablePrime(certainty: any, search_max: any): KonpeitoInteger

Next prime.

public

Logical Not.

public

or(number: any): KonpeitoInteger

Logical OR.

public

pow(exponent: any): KonpeitoInteger

Power function.

public

rem(number: any): KonpeitoInteger

Remainder of division.

public

remainder(number: any): KonpeitoInteger

Remainder of division.

public

Rounding to the nearest integer.

public

Multiply a multiple of ten.

public

this << n

public

sign(): any

The positive or negative sign of this number.

public

signum(): any

The positive or negative sign of this number.

public

Square.

public

sub(number: any): KonpeitoInteger

Subtract.

public

subtract(number: any): KonpeitoInteger

Subtract.

public

return BigDecimal.

public

return BigInteger.

public

return Complex.

public

return Fraction.

public

Convert to JSON.

public

return Matrix.

public

Convert to string.

public

xor(number: any): KonpeitoInteger

Logical Exclusive-OR.

From class KonpeitoFloat
public static get

E, Napier's constant.

public static get

0.5

public static get

0.5 * PI.

public static get

log_e(10)

public static get

log_e(2)

public static get

log_10(e)

public static get

log_2(e)

public static get

PI.

public static get

0.25 * PI.

public static get

sqrt(0.5)

public static get

sqrt(2)

public static get

2 * PI.

public

Arc cosine function.

public

Inverse hyperbolic cosine function.

public

Inverse cotangent function.

public

Inverse hyperbolic cotangent function.

public

Inverse cosecant function.

public

Inverse hyperbolic cosecant function.

public

Reverse secant function.

public

Inverse hyperbolic secant function.

public

Arc sine function.

public

Inverse hyperbolic sine function.

public

Atan (arc tangent) function.

public

atan2(number: any): KonpeitoFloat

Atan (arc tangent) function.

public

Inverse hyperbolic tangent function.

public

Cube root.

public

Cosine function.

public

Hyperbolic cosine function.

public

Cotangent function.

public

Hyperbolic cotangent function.

public

Cosecant function.

public

Hyperbolic cosecant function.

public

Exponential function.

public

e^x - 1

public

Logarithmic function.

public

log_10(x)

public

ln(1 + x)

public

log_2(x)

public

Logit function.

public

Reciprocal square root.

public

Secant function.

public

Hyperbolic secant function.

public

Sine function.

public

Normalized sinc function.

public

Hyperbolic sine function.

public

Square root.

public

Tangent function.

public

Hyperbolic tangent function.

Static Public Members

public static get E: BigDecimal: * source

E, Napier's constant.

Override:

KonpeitoFloat#E

Return:

BigDecimal

E

public static get HALF: BigDecimal: * source

0.5

Override:

KonpeitoFloat#HALF

Return:

BigDecimal

0.5

public static get HALF_PI: BigDecimal: * source

0.5 * PI.

Override:

KonpeitoFloat#HALF_PI

Return:

BigDecimal

1.57...

public static get LN10: BigDecimal: * source

log_e(10)

Override:

KonpeitoFloat#LN10

Return:

BigDecimal

ln(10)

public static get LN2: BigDecimal: * source

log_e(2)

Override:

KonpeitoFloat#LN2

Return:

BigDecimal

ln(2)

public static get LOG10E: BigDecimal: * source

log_10(e)

Override:

KonpeitoFloat#LOG10E

Return:

BigDecimal

log_10(e)

public static get LOG2E: BigDecimal: * source

log_2(e)

Override:

KonpeitoFloat#LOG2E

Return:

BigDecimal

log_2(e)

public static get MINUS_ONE: BigDecimal: * source

-1

Override:

KonpeitoInteger#MINUS_ONE

Return:

BigDecimal

1

public static get NEGATIVE_INFINITY: BigDecimal: * source

Negative Infinity.

Override:

KonpeitoInteger#NEGATIVE_INFINITY

Return:

BigDecimal

Infinity

public static get NaN: BigDecimal: * source

Not a Number.

Override:

KonpeitoInteger#NaN

Return:

BigDecimal

NaN

public static get ONE: BigDecimal: * source

1

Override:

KonpeitoInteger#ONE

Return:

BigDecimal

1

public static get PI: BigDecimal: * source

PI

Override:

KonpeitoFloat#PI

Return:

BigDecimal

3.14...

public static get POSITIVE_INFINITY: BigDecimal: * source

Positive infinity.

Override:

KonpeitoInteger#POSITIVE_INFINITY

Return:

BigDecimal

Infinity

public static get QUARTER_PI: BigDecimal: * source

0.25 * PI.

Override:

KonpeitoFloat#QUARTER_PI

Return:

BigDecimal

0.78...

public static get SQRT1_2: BigDecimal: * source

sqrt(0.5)

Override:

KonpeitoFloat#SQRT1_2

Return:

BigDecimal

sqrt(0.5)

public static get SQRT2: BigDecimal: * source

sqrt(2)

Override:

KonpeitoFloat#SQRT2

Return:

BigDecimal

sqrt(2)

public static get TEN: BigDecimal: * source

10

Override:

KonpeitoInteger#TEN

Return:

BigDecimal

10

public static get TWO: BigDecimal: * source

2

Override:

KonpeitoInteger#TWO

Return:

BigDecimal

2

public static get TWO_PI: BigDecimal: * source

2 * PI.

Override:

KonpeitoFloat#TWO_PI

Return:

BigDecimal

6.28...

public static get ZERO: BigDecimal: * source

0

Override:

KonpeitoInteger#ZERO

Return:

BigDecimal

0

Static Public Methods

public static create(number: KBigDecimalInputData): BigDecimal source

Create an arbitrary-precision floating-point number.

Initialization can be performed as follows.

  • 1200, "1200", "12e2", "1.2e3"
  • When initializing with array. [ integer, [scale = 0], [context=default]].
  • When initializing with object. { integer, [scale = 0], [context=default]}.

Description of the settings are as follows, you can also omitted.

  • The "scale" is an integer scale factor.
  • The "context" is used to normalize the created floating point.

If "context" is not specified, the "default_context" set for the class is used. The "context" is the used when no environment settings are specified during calculation.

Override:

KonpeitoInteger#create

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Real data.

Return:

BigDecimal

public static getDefaultContext(): MathContext source

Return default MathContext class.

  • Used when MathContext not specified explicitly.

Return:

MathContext

public static popDefaultContext() source

Pop default the MathContext.

  • Use with pushDefaultContext when you want to switch settings temporarily.

public static pushDefaultContext(context: MathContext) source

Push default the MathContext.

  • Use with popDefaultContext when you want to switch settings temporarily.

Params:

NameTypeAttributeDescription
context MathContext
  • optional

public static rand(random: Random): BigDecimal source

Create random values with uniform random numbers.

Params:

NameTypeAttributeDescription
random Random
  • optional

Class for creating random numbers.

Return:

BigDecimal

public static randn(random: Random): BigDecimal source

Create random values with normal distribution.

Params:

NameTypeAttributeDescription
random Random
  • optional

Class for creating random numbers.

Return:

BigDecimal

public static setDefaultContext(context: MathContext) source

Set default the MathContext.

  • This is used if you do not specify MathContext when creating a new object.

Params:

NameTypeAttributeDescription
context MathContext
  • optional
  • default: MathContext.DECIMAL128

public static valueOf(x: KBigDecimalLocalInputData, scale: MathContext): BigDecimal source

Convert number to BigDecimal type.

Override:

KonpeitoInteger#valueOf

Params:

NameTypeAttributeDescription
x KBigDecimalLocalInputData
scale MathContext
  • optional

Return:

BigDecimal

Public Constructors

public constructor(number: KBigDecimalInputData) source

Create an arbitrary-precision floating-point number.

Initialization can be performed as follows.

  • 1200, "1200", "12e2", "1.2e3"
  • When initializing with array. [ integer, [scale = 0], [context=default]].
  • When initializing with object. { integer, [scale = 0], [context=default]}.

Description of the settings are as follows, you can also omitted.

  • The "scale" is an integer scale factor.
  • The "context" is used to normalize the created floating point.

If "context" is not specified, the "default_context" set for the class is used. The "context" is the used when no environment settings are specified during calculation.

Override:

KonpeitoFloat#constructor

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Real data.

Public Members

public get booleanValue: boolean: * source

boolean value.

Override:

KonpeitoInteger#booleanValue

Return:

boolean

public get doubleValue: number: * source

64-bit floating point.

Override:

KonpeitoInteger#doubleValue

Return:

number

public get floatValue: number: * source

32-bit floating point.

Return:

number

public get intValue: number: * source

32-bit integer value.

Override:

KonpeitoInteger#intValue

Return:

number

public get intValueExact: number: * source

32-bit integer value. An error occurs if conversion fails.

Return:

number

Public Methods

public abs(): BigDecimal source

Absolute value.

Override:

KonpeitoInteger#abs

Return:

BigDecimal

abs(A)

public acos(): BigDecimal source

Arc cosine function.

Override:

KonpeitoFloat#acos

Return:

BigDecimal

acos(A)

public acosh(): BigDecimal source

Inverse hyperbolic cosine function.

Override:

KonpeitoFloat#acosh

Return:

BigDecimal

acosh(A)

public acot(): BigDecimal source

Inverse cotangent function.

Override:

KonpeitoFloat#acot

Return:

BigDecimal

acot(A)

public acoth(): BigDecimal source

Inverse hyperbolic cotangent function.

Override:

KonpeitoFloat#acoth

Return:

BigDecimal

acoth(A)

public acsc(): BigDecimal source

Inverse cosecant function.

Override:

KonpeitoFloat#acsc

Return:

BigDecimal

acsc(A)

public acsch(): BigDecimal source

Inverse hyperbolic cosecant function.

Override:

KonpeitoFloat#acsch

Return:

BigDecimal

acsch(A)

public add(number: KBigDecimalInputData): BigDecimal source

Add.

Override:

KonpeitoInteger#add

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A + B

public and(number: KBigDecimalInputData): BigDecimal source

Logical AND.

  • Calculated as an integer.

Override:

KonpeitoInteger#and

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A & B

public asec(): BigDecimal source

Reverse secant function.

Override:

KonpeitoFloat#asec

Return:

BigDecimal

asec(A)

public asech(): BigDecimal source

Inverse hyperbolic secant function.

Override:

KonpeitoFloat#asech

Return:

BigDecimal

asech(A)

public asin(): BigDecimal source

Arc sine function.

Override:

KonpeitoFloat#asin

Return:

BigDecimal

asin(A)

public asinh(): BigDecimal source

Inverse hyperbolic sine function.

Override:

KonpeitoFloat#asinh

Return:

BigDecimal

asinh(A)

public atan(): BigDecimal source

Atan (arc tangent) function.

  • Return the values of [-PI/2, PI/2].

Override:

KonpeitoFloat#atan

Return:

BigDecimal

atan(A)

public atan2(number: KBigDecimalInputData, context: MathContext): BigDecimal source

Atan (arc tangent) function. Return the values of [-PI, PI] . Supports only real numbers.

Override:

KonpeitoFloat#atan2

Params:

NameTypeAttributeDescription
number KBigDecimalInputData
context MathContext
  • optional

MathContext setting after calculation. If omitted, use the MathContext of the B.

Return:

BigDecimal

atan2(Y, X)

public atanh(): BigDecimal source

Inverse hyperbolic tangent function.

Override:

KonpeitoFloat#atanh

Return:

BigDecimal

atanh(A)

public cbrt(): BigDecimal source

Cube root.

Override:

KonpeitoFloat#cbrt

Return:

BigDecimal

cbrt(A)

public ceil(): BigDecimal source

Ceil.

Override:

KonpeitoInteger#ceil

Return:

BigDecimal

ceil(A)

public clip(min: KBigDecimalInputData, max: KBigDecimalInputData): BigDecimal source

Clip number within range.

Params:

NameTypeAttributeDescription
min KBigDecimalInputData
max KBigDecimalInputData

Return:

BigDecimal

min(max(x, min), max)

public clone(): BigDecimal source

Deep copy.

Override:

KonpeitoInteger#clone

Return:

BigDecimal

public compareTo(number: KBigDecimalInputData, tolerance: KBigDecimalInputData): number source

Compare values.

Override:

KonpeitoInteger#compareTo

Params:

NameTypeAttributeDescription
number KBigDecimalInputData
tolerance KBigDecimalInputData
  • optional
  • default: 0

Calculation tolerance of calculation.

Return:

number

A > B ? 1 : (A === B ? 0 : -1)

public cos(): BigDecimal source

Cosine function.

Override:

KonpeitoFloat#cos

Return:

BigDecimal

cos(A)

public cosh(): BigDecimal source

Hyperbolic cosine function.

Override:

KonpeitoFloat#cosh

Return:

BigDecimal

cosh(A)

public cot(): BigDecimal source

Cotangent function.

Override:

KonpeitoFloat#cot

Return:

BigDecimal

cot(A)

public coth(): BigDecimal source

Hyperbolic cotangent function.

Override:

KonpeitoFloat#coth

Return:

BigDecimal

coth(A)

public csc(): BigDecimal source

Cosecant function.

Override:

KonpeitoFloat#csc

Return:

BigDecimal

csc(A)

public csch(): BigDecimal source

Hyperbolic cosecant function.

Override:

KonpeitoFloat#csch

Return:

BigDecimal

csch(A)

public div(number: KBigDecimalInputData, type: MathContext | KBigDecimalDivideType): BigDecimal source

Divide.

  • The argument can specify the scale after calculation.
  • In the case of precision infinity, it may generate an error by a repeating decimal.
  • When "{}" is specified for the argument, it is calculated on the scale of "this.scale() - divisor.scale()".
  • When null is specified for the argument, it is calculated on the scale of "divisor.context".

Override:

KonpeitoInteger#div

Params:

NameTypeAttributeDescription
number KBigDecimalInputData
type MathContext | KBigDecimalDivideType
  • optional

Scale, MathContext, RoundingMode used for the calculation.

Return:

BigDecimal

public divide(number: KBigDecimalInputData, type: MathContext | KBigDecimalDivideType): BigDecimal source

Divide.

  • The argument can specify the scale after calculation.
  • In the case of precision infinity, it may generate an error by a repeating decimal.
  • When "{}" is specified for the argument, it is calculated on the scale of "this.scale() - divisor.scale()".
  • When null is specified for the argument, it is calculated on the scale of "divisor.context".

Override:

KonpeitoInteger#divide

Params:

NameTypeAttributeDescription
number KBigDecimalInputData
type MathContext | KBigDecimalDivideType
  • optional

Scale, MathContext, RoundingMode used for the calculation.

Return:

BigDecimal

A / B

public divideAndRemainder(number: KBigDecimalInputData): Array<BigDecimal> source

Divide and remainder.

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

Array<BigDecimal>

[C = (int)(A / B), A - C * B]

public divideToIntegralValue(number: KBigDecimalInputData): BigDecimal source

Divide not calculated to the decimal point.

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

(int)(A / B)

public equals(number: KBigDecimalInputData, tolerance: KBigDecimalInputData): boolean source

Equals.

  • Attention : Test for equality, including the precision and the scale.
  • Use the "compareTo" if you only want to find out whether they are also mathematically equal.
  • If you specify a "tolerance", it is calculated by ignoring the test of the precision and the scale.

Override:

KonpeitoInteger#equals

Params:

NameTypeAttributeDescription
number KBigDecimalInputData
tolerance KBigDecimalInputData
  • optional

Calculation tolerance of calculation.

Return:

boolean

A === B

public equalsState(number: KBigDecimalInputData): boolean source

Numeric type match.

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

boolean

public exp(): BigDecimal source

Exponential function.

Override:

KonpeitoFloat#exp

Return:

BigDecimal

exp(A)

public expm1(): BigDecimal source

e^x - 1

Override:

KonpeitoFloat#expm1

Return:

BigDecimal

expm1(A)

public extgcd(number: KBigDecimalInputData): Array<BigDecimal> source

Extended Euclidean algorithm.

  • Calculated as an integer.

Override:

KonpeitoInteger#extgcd

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

Array<BigDecimal>

[a, b, gcd(x, y)], Result of calculating ax + by = gcd(x, y).

public factor(): BigDecimal[] source

Factorization.

  • Calculated as an integer.
  • Calculate up to 9007199254740991.

Override:

KonpeitoInteger#factor

Return:

BigDecimal[]

factor

public factorial(): BigDecimal source

Factorial function, x!.

  • Supports only integers.

Override:

KonpeitoInteger#factorial

Return:

BigDecimal

n!

public fix(): BigDecimal source

To integer rounded down to the nearest.

Override:

KonpeitoInteger#fix

Return:

BigDecimal

fix(A), trunc(A)

public floor(): BigDecimal source

Floor.

Override:

KonpeitoInteger#floor

Return:

BigDecimal

floor(A)

public fract(): BigDecimal source

Fraction.

Override:

KonpeitoInteger#fract

Return:

BigDecimal

fract(A)

public gcd(number: KBigDecimalInputData): BigDecimal source

Euclidean algorithm.

  • Calculated as an integer.

Override:

KonpeitoInteger#gcd

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

gcd(x, y)

public inv(): BigDecimal source

Inverse number of this value.

Override:

KonpeitoInteger#inv

Return:

BigDecimal

1 / A

public isFinite(): boolean source

Return true if the value is finite number.

Override:

KonpeitoInteger#isFinite

Return:

boolean

!isNaN(A) && !isInfinite(A)

public isInfinite(): boolean source

this === Infinity or -Infinity

Override:

KonpeitoInteger#isInfinite

Return:

boolean

isPositiveInfinity(A) || isNegativeInfinity(A)

public isInteger(tolerance: KBigDecimalInputData): boolean source

Return true if the value is integer.

Params:

NameTypeAttributeDescription
tolerance KBigDecimalInputData
  • optional
  • default: 0

Calculation tolerance of calculation.

Return:

boolean

public isNaN(): boolean source

this === NaN

Override:

KonpeitoInteger#isNaN

Return:

boolean

isNaN(A)

public isNegative(): boolean source

this < 0

Override:

KonpeitoInteger#isNegative

Return:

boolean

public isNegativeInfinity(): boolean source

this === -Infinity

Override:

KonpeitoInteger#isNegativeInfinity

Return:

boolean

isNegativeInfinity(A)

public isNotNegative(): boolean source

this >= 0

Override:

KonpeitoInteger#isNotNegative

Return:

boolean

public isOne(tolerance: KBigDecimalInputData): boolean source

this === 1

Override:

KonpeitoInteger#isOne

Params:

NameTypeAttributeDescription
tolerance KBigDecimalInputData
  • optional
  • default: 0

Calculation tolerance of calculation.

Return:

boolean

public isPositive(): boolean source

this > 0

Override:

KonpeitoInteger#isPositive

Return:

boolean

public isPositiveInfinity(): boolean source

this === Infinity

Override:

KonpeitoInteger#isPositiveInfinity

Return:

boolean

isPositiveInfinity(A)

public isPrime(): boolean source

Return true if the value is prime number.

  • Calculated as an integer.
  • Calculate up to 2251799813685248(=2^51).

Override:

KonpeitoInteger#isPrime

Return:

boolean

If the calculation range is exceeded, null is returned.

public isProbablePrime(certainty: KBigDecimalInputData): boolean source

Return true if the value is prime number by Miller-Labin prime number determination method.

Attention : it takes a very long time to process.

  • Calculated as an integer.

Override:

KonpeitoInteger#isProbablePrime

Params:

NameTypeAttributeDescription
certainty KBigDecimalInputData
  • optional
  • default: 100

Repeat count (prime precision).

Return:

boolean

public isZero(tolerance: KBigDecimalInputData): boolean source

this === 0

Override:

KonpeitoInteger#isZero

Params:

NameTypeAttributeDescription
tolerance KBigDecimalInputData
  • optional
  • default: 0

Calculation tolerance of calculation.

Return:

boolean

public lcm(number: KBigDecimalInputData): BigDecimal source

Least common multiple.

  • Calculated as an integer.

Override:

KonpeitoInteger#lcm

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

lcm(x, y)

public log(): BigDecimal source

Logarithmic function.

Override:

KonpeitoFloat#log

Return:

BigDecimal

log(A)

public log10(): BigDecimal source

log_10(x)

Override:

KonpeitoFloat#log10

Return:

BigDecimal

log10(A)

public log1p(): BigDecimal source

ln(1 + x)

Override:

KonpeitoFloat#log1p

Return:

BigDecimal

log1p(A)

public log2(): BigDecimal source

log_2(x)

Override:

KonpeitoFloat#log2

Return:

BigDecimal

log2(A)

public logit(): BigDecimal source

Logit function.

Override:

KonpeitoFloat#logit

Return:

BigDecimal

logit(A)

public max(number: KBigDecimalInputData): BigDecimal source

Maximum number.

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

max([A, B])

public min(number: KBigDecimalInputData): BigDecimal source

Minimum number.

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

min([A, B])

public mod(number: KBigDecimalInputData): BigDecimal source

Modulo, positive remainder of division.

  • Result has same sign as the Divisor.

Override:

KonpeitoInteger#mod

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A mod B

public modInverse(m: KBigDecimalInputData): BigDecimal source

Modular multiplicative inverse.

  • Calculated as an integer.

Override:

KonpeitoInteger#modInverse

Params:

NameTypeAttributeDescription
m KBigDecimalInputData

Return:

BigDecimal

A^(-1) mod m

public modPow(exponent: KBigDecimalInputData, m: KBigDecimalInputData): BigDecimal source

Modular exponentiation.

  • Calculated as an integer.

Override:

KonpeitoInteger#modPow

Params:

NameTypeAttributeDescription
exponent KBigDecimalInputData
m KBigDecimalInputData

Return:

BigDecimal

A^B mod m

public movePointLeft(n: KBigDecimalInputData): BigDecimal source

Move the decimal point to the left.

Params:

NameTypeAttributeDescription
n KBigDecimalInputData

Return:

BigDecimal

public movePointRight(n: KBigDecimalInputData): BigDecimal source

Move the decimal point to the right.

Params:

NameTypeAttributeDescription
n KBigDecimalInputData

Return:

BigDecimal

public mul(number: KBigDecimalInputData): BigDecimal source

Multiply.

Override:

KonpeitoInteger#mul

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A * B

public multiply(number: KBigDecimalInputData): BigDecimal source

Multiply.

Override:

KonpeitoInteger#multiply

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A * B

public negate(): BigDecimal source

this * -1

Override:

KonpeitoInteger#negate

Return:

BigDecimal

A

public nextProbablePrime(certainty: KBigDecimalInputData, search_max: KBigDecimalInputData): BigDecimal source

Next prime.

Override:

KonpeitoInteger#nextProbablePrime

Params:

NameTypeAttributeDescription
certainty KBigDecimalInputData
  • optional
  • default: 100

Repeat count (prime precision).

search_max KBigDecimalInputData
  • optional
  • default: 100000

Search range of next prime.

Return:

BigDecimal

public not(): BigDecimal source

Logical Not. (mutable)

  • Calculated as an integer.

Override:

KonpeitoInteger#not

Return:

BigDecimal

!A

public or(number: KBigDecimalInputData): BigDecimal source

Logical OR.

  • Calculated as an integer.

Override:

KonpeitoInteger#or

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A | B

public plus(): BigDecimal source

this * 1

Return:

BigDecimal

+A

public pow(number: KBigDecimalInputData): BigDecimal source

Power function.

  • An exception occurs when doing a huge multiplication.

Override:

KonpeitoInteger#pow

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

pow(A, B)

public precision(): number source

Precision.

Return:

number

public rem(number: KBigDecimalInputData): BigDecimal source

Remainder of division.

  • Result has same sign as the Dividend.

Override:

KonpeitoInteger#rem

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A % B

public remainder(number: KBigDecimalInputData): BigDecimal source

Remainder of division.

  • Result has same sign as the Dividend.

Override:

KonpeitoInteger#remainder

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A % B

public round(mc: MathContext): BigDecimal source

Round with specified settings.

  • This method is not a method round the decimal point.
  • This method converts numbers in the specified Context and rounds unconvertible digits.

Use this.setScale(0, RoundingMode.HALF_UP) if you want to round the decimal point. When the argument is omitted, such decimal point rounding operation is performed.

Override:

KonpeitoInteger#round

Params:

NameTypeAttributeDescription
mc MathContext
  • optional

New setting.

Return:

BigDecimal

public rsqrt(): BigDecimal source

Reciprocal square root.

Override:

KonpeitoFloat#rsqrt

Return:

BigDecimal

rsqrt(A)

public scale(): number source

The scale of this BigDecimal.

Return:

number

public scaleByPowerOfTen(n: KBigDecimalInputData): BigDecimal source

Multiply a multiple of ten.

  • Supports only integers.
  • Only the scale is changed without changing the precision.

Override:

KonpeitoInteger#scaleByPowerOfTen

Params:

NameTypeAttributeDescription
n KBigDecimalInputData

Return:

BigDecimal

A * 10^floor(n)

public sec(): BigDecimal source

Secant function.

Override:

KonpeitoFloat#sec

Return:

BigDecimal

sec(A)

public sech(): BigDecimal source

Hyperbolic secant function.

Override:

KonpeitoFloat#sech

Return:

BigDecimal

sech(A)

public setScale(new_scale: KBigDecimalInputData, rounding_mode: RoundingModeEntity): BigDecimal source

Change the scale.

Params:

NameTypeAttributeDescription
new_scale KBigDecimalInputData

New scale.

rounding_mode RoundingModeEntity
  • optional
  • default: RoundingMode.UNNECESSARY

Rounding method when converting precision.

Return:

BigDecimal

public shift(n: KBigDecimalInputData): BigDecimal source

this << n

  • Calculated as an integer.

Override:

KonpeitoInteger#shift

Params:

NameTypeAttributeDescription
n KBigDecimalInputData

Return:

BigDecimal

A << n

public sign(): number source

The positive or negative sign of this number.

  • +1 if positive, -1 if negative, 0 if 0.

Override:

KonpeitoInteger#sign

Return:

number

public signum(): number source

The positive or negative sign of this number.

  • +1 if positive, -1 if negative, 0 if 0.

Override:

KonpeitoInteger#signum

Return:

number

public sin(): BigDecimal source

Sine function.

Override:

KonpeitoFloat#sin

Return:

BigDecimal

sin(A)

public sinc(): BigDecimal source

Normalized sinc function.

Override:

KonpeitoFloat#sinc

Return:

BigDecimal

sinc(A)

public sinh(): BigDecimal source

Hyperbolic sine function.

Override:

KonpeitoFloat#sinh

Return:

BigDecimal

sinh(A)

public sqrt(): BigDecimal source

Square root.

Override:

KonpeitoFloat#sqrt

Return:

BigDecimal

sqrt(A)

public square(): BigDecimal source

Square.

Override:

KonpeitoInteger#square

Return:

BigDecimal

A^2

public stripTrailingZeros(): BigDecimal source

Remove the 0 to the right of the numbers and normalize the scale.

Return:

BigDecimal

public sub(number: KBigDecimalInputData): BigDecimal source

Subtract.

Override:

KonpeitoInteger#sub

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A - B

public subtract(number: KBigDecimalInputData): BigDecimal source

Subtract.

Override:

KonpeitoInteger#subtract

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A - B

public tan(): BigDecimal source

Tangent function.

Override:

KonpeitoFloat#tan

Return:

BigDecimal

tan(A)

public tanh(): BigDecimal source

Hyperbolic tangent function.

Override:

KonpeitoFloat#tanh

Return:

BigDecimal

tanh(A)

public toBigDecimal(mc: MathContext): BigDecimal source

return BigDecimal.

Override:

KonpeitoInteger#toBigDecimal

Params:

NameTypeAttributeDescription
mc MathContext
  • optional

MathContext setting after calculation.

Return:

BigDecimal

public toBigInteger(): BigInteger source

return BigInteger.

Override:

KonpeitoInteger#toBigInteger

Return:

BigInteger

public toComplex(): Complex source

return Complex.

Override:

KonpeitoInteger#toComplex

Return:

Complex

public toEngineeringString(): string source

Convert to string usding technical notation.

Return:

string

public toFraction(): Fraction source

return Fraction.

Override:

KonpeitoInteger#toFraction

Return:

Fraction

public toJSON(): string source

Convert to JSON.

Override:

KonpeitoInteger#toJSON

Return:

string

public toMatrix(): Matrix source

return Matrix.

Override:

KonpeitoInteger#toMatrix

Return:

Matrix

public toPlainString(): string source

Convert to string without exponential notation.

Return:

string

public toScientificNotation(e_len: KBigDecimalInputData): string source

Convert to string using scientific notation.

Params:

NameTypeAttributeDescription
e_len KBigDecimalInputData

Number of digits in exponent part.

Return:

string

public toString(): string source

Convert to string.

Override:

KonpeitoInteger#toString

Return:

string

public trunc(): BigDecimal source

To integer rounded down to the nearest.

Return:

BigDecimal

fix(A), trunc(A)

public ulp(): BigDecimal source

The smallest value that can be represented with the set precision.

Return:

BigDecimal

public unscaledValue(): BigInteger source

An integer with the exponent part removed.

Return:

BigInteger

public xor(number: KBigDecimalInputData): BigDecimal source

Logical Exclusive-OR.

  • Calculated as an integer.

Override:

KonpeitoInteger#xor

Params:

NameTypeAttributeDescription
number KBigDecimalInputData

Return:

BigDecimal

A ^ B

Private Methods

private _getUnsignedIntegerString(): string source

Return string of this number without sign. If cache is already created, return cache.

Return:

string