Variable: MC
ts
const MC: MathContextConstructor;Defined in: bigdecimal.ts:5110
Constructor function for MathContext. Can be invoked with new or without new.
Sample Usage:
javascript
const { Big, MC, RoundingMode } = require('bigdecimal.js');
const x = Big('1');
const y = Big('3');
const res1 = x.divideWithMathContext(y, new MC(3));
console.log(res1.toString()); // 0.333
// You can also use without `new` operator
const res2 = x.divideWithMathContext(y, MC(3, RoundingMode.UP));
console.log(res2.toString()); // 0.334
try {
x.divide(y);
// throws since full precision is requested but it is not possible
} catch (e) {
console.log(e); // RangeError: Non-terminating decimal expansion; no exact representable decimal result.
}Param
precision
Precision value
Param
roundingMode
Optional rounding Mode. By default RoundingMode.HALF_UP.