vue page displaying decimal places Problem

   A few days ago, wrote a echarts proportion of map data, had written no problem, fast on the line, was suddenly told, the data show the number of decimal places unreasonable ah, as shown below:

 Interface returns the data as shown above, I saw this simple ah, use parseFloat (value) .toFixed (3), this formula is not solved it, go onto this formula, full of confidence did not test it submitted as a result, in the afternoon and was told that the data or inappropriate, the median there are problems, as shown below:

A look, not ah, how some data is correct, some incorrect display it, or want a solid foundation of knowledge does not lead, in fact, 0.1 + 0.2 + 0.200000000000000011102230246251565404236316680908203125 that such 0.1000000000000000055511151231257827021181583404541015625 = 0.3000000000000000444089209850062616169452667236328125, so that the above formula will fail, ultimately, in other ways, (value * 100) .toFixed (3), to deal with, so out of data really is the desired result.

 

Published 23 original articles · won praise 7 · views 20000 +

Guess you like

Origin blog.csdn.net/ghd602338792/article/details/103580548