// You can also use without `new` operator constres2 = 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.
Constructor function for MathContext. Can be invoked with new or without new.
Sample Usage: