Home Reference Source
public class | source

MathContext

Configuration class for BigDecimal (immutable).

Static Member Summary

Static Public Members
public static get

128-bit floating point.

public static get

256-bit floating point.

public static get

32-bit floating point.

public static get

64-bit floating point.

public static get

No decimal point limit.

Static Method Summary

Static Public Methods
public static

create(precision_or_name: string | number | MathContext, roundingMode: RoundingModeEntity): MathContext

Create BigDecimal configuration.

Constructor Summary

Public Constructor
public

constructor(precision_or_name: string | number | MathContext, roundingMode: RoundingModeEntity)

Create BigDecimal configuration.

Member Summary

Private Members
private

The precision of this BigDecimal.

private

Method of rounding.

Method Summary

Public Methods
public

Decrease in the precision of x.

public

Equals.

public

The precision of this BigDecimal.

public

Method of rounding.

public

Increase in the precision of x.

public

Convert to string.

Static Public Members

public static get DECIMAL128: MathContext: * source

128-bit floating point.

  • Significand precision: 112 bits
  • Equivalent of the C language long double.

Return:

MathContext

public static get DECIMAL256: MathContext source

256-bit floating point.

  • Significand precision: 237 bits

public static get DECIMAL32: MathContext: * source

32-bit floating point.

  • Significand precision: 23 bits
  • Equivalent of the C language float.

Return:

MathContext

public static get DECIMAL64: MathContext: * source

64-bit floating point.

  • Significand precision: 52 bits
  • Equivalent of the C language double.

Return:

MathContext

public static get UNLIMITED: MathContext: * source

No decimal point limit. However, an error occurs in the case of cyclic fraction in division.

Return:

MathContext

Static Public Methods

public static create(precision_or_name: string | number | MathContext, roundingMode: RoundingModeEntity): MathContext source

Create BigDecimal configuration.

Params:

NameTypeAttributeDescription
precision_or_name string | number | MathContext

Precision. Or String output by MathContext.toString.

roundingMode RoundingModeEntity
  • optional
  • default: RoundingMode.HALF_UP

RoundingMode.

Return:

MathContext

Public Constructors

public constructor(precision_or_name: string | number | MathContext, roundingMode: RoundingModeEntity) source

Create BigDecimal configuration.

Params:

NameTypeAttributeDescription
precision_or_name string | number | MathContext

Precision. Or String output by MathContext.toString.

roundingMode RoundingModeEntity
  • optional
  • default: RoundingMode.HALF_UP

RoundingMode.

Private Members

private precision: number source

The precision of this BigDecimal.

private roundingMode: RoundingModeEntity source

Method of rounding.

Public Methods

public decreasePrecision(x: number): MathContext source

Decrease in the precision of x.

  • If the setting has no precision limit, do not change.

Params:

NameTypeAttributeDescription
x number
  • optional
  • default: 1

Return:

MathContext

public equals(x: MathContext): boolean source

Equals.

Params:

NameTypeAttributeDescription
x MathContext

Number to compare.

Return:

boolean

public getPrecision(): number source

The precision of this BigDecimal.

Return:

number

public getRoundingMode(): RoundingModeEntity source

Method of rounding.

public increasePrecision(x: number): MathContext source

Increase in the precision of x.

  • If the setting has no precision limit, do not change.

Params:

NameTypeAttributeDescription
x number
  • optional
  • default: 1

Return:

MathContext

public toString(): string source

Convert to string.

Return:

string