How are floating point operations performed in js?
For example: var a=0.69;
I want to get 6.9 by writing var c=a*10;
alert(c); The result is: 6.8999999999999995
After searching online, some netizens said that this is a JS floating point calculation bug and found a solution:
Method 1: Have js custom function
Method 2: If you know the number of decimal places, you can consider amplifying the floating point number to an integer (and finally dividing it by the corresponding multiple), and then Perform calculation operations so that you can get the correct result
alert(11*22.9);//Get 251.89999999999998
alert(11*(22.9*10)/10);//Get 251.9