Home > Web Front-end > JS Tutorial > A brief analysis of floating point arithmetic problems in js_javascript skills

A brief analysis of floating point arithmetic problems in js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:05:18
Original
1028 people have browsed it

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

Copy code Code As follows:

Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template