I am trying to deal with JavaScript values ββsuch as 23.45, but I want to be able to perform mathematical operations on these values ββ(addition, subtraction, multiplication, division) without using floating point problems. Yes, I sometimes need to round results, but I would like them to give reasonable answers.
Consider this in javascript:
24.56 * .3
Productivity
7.36799999999
I would like it to come out with 7.368.
Most languages ββhave a decimal or currency type to handle this. Has anyone created a class that can handle this kind of data efficiently, or is there any other solution for working with these types of numbers without constantly correcting floating point errors?
source share