Feature request and related problem
As mentioned in the docs, the round() function always rounds half away from zero.
Sometimes we want to round towards zero instead:
// positive numbers
3.7 -> 3
4.5 -> 4
12.3 -> 12
// negative numbers
-2.9 -> 2
-3.5 -> -3
-65.2 -> -65
This was originally mention in #227
The Javascript Math.trunc() method achieves this.
And MathJs (The library used internally by this library) has a fix() method, which also does this, but has the benefit of also allowing you to specify the number of decimals.
Suggested solution
I propose that we enable a fix() function, which uses the MathJs fix() function, and also an alias for it of trunc(), so those familiar with that method can use it.
Alternatives
No response
Additional context
No response
Feature request and related problem
As mentioned in the docs, the
round()function always rounds half away from zero.Sometimes we want to round towards zero instead:
This was originally mention in #227
The Javascript
Math.trunc()method achieves this.And MathJs (The library used internally by this library) has a
fix()method, which also does this, but has the benefit of also allowing you to specify the number of decimals.Suggested solution
I propose that we enable a
fix()function, which uses the MathJsfix()function, and also an alias for it oftrunc(), so those familiar with that method can use it.Alternatives
No response
Additional context
No response