I've been having an issue with my JavaScript code where in the final verification step of a form, it sums the values to determine whether or not their total sum is equivalent to 100. Normally, it works as intended, but occasionally it will indicate that there is an issue if, for example, the values are: 9.325210871602625 and 90.67478912839736. These values' sum should be accepted, yet it is not.
As far as I can tell, the calculations that are performed to acquire these values are correct so I do not believe that they are the source of error, and frankly there is far too much code involved in calculating their values to display here anyway.
Obviously I could just loosen the requirements so that any value that falls in the range of (99.99 - 100.01) would be accepted such as:
let valuesOK = sumValues("example") > 99.99 && sumValues("example1") < 100.01;
but that doesn't seem like a proper solution.
My only theory is that because both numbers have 16 digits in the case that I provided (9.325210871602625 and 90.67478912839736), however because 9.325... has one extra decimal place than 90.674..., that that may be causing problems when adding them together. Regardless, I'm not sure how to elegantly solve that issue if my theory is indeed correct.
I'd appreciate any help or references to documentation that might make sense of my issue.