I'm using the toFixed () function of javascript to display values with two decimal places ( toFixed (2) to display 2 digits after the decimal point).
The problem occurs that I have two situations where the value has three digits after the decimal point, which ends with the number 5 and the rounding behavior is different from both. One he applies the rule:
"If the number prior to the decimal point you want to round is greater than or equal to 5, you must increase by 1 in the decimal place chosen for rounding. If the number is less than 5, decimal places that do not interest us, and the number does not change. "
Only the other does not apply.
Example
console.log('Resultado: ' + 6.825.toFixed(2))
console.log('Resultado: ' + 4.925.toFixed(2))
Both of them should have the same behavior, has anyone ever had this problem?
Note: I've tried using the toPrecision () function but it did not work for me.