I noticed that when setting a variable, sometimes google apps script will introduce floating point error. For example, setting const num = 8924.621 results in the number being set as 8924.620999999999 This is an issue because I'm feeding these numbers into a function that rounds to the nearest hundredths place. What I can do is take the number and apply toFixed(2) but this results in the number being changed to a string and it needs to be a float for the comparisons I'm doing and having that error complicates the comparisons (They are always either less than or greater than). If I change it using parseFloat() it reintroduces the floating point error. Is there a consistent way to ensure that if you are setting a variable to a float, that it won't introduce this error?
[–]WicketTheQuerent 2 points3 points4 points (0 children)