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

WBOY
Release: 2016-05-16 17:05:18
Original
1004 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:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template