This is a famous problem in computer world. It is originated from the IEEE 754 spec and binary system. Let’s see the problem at JavaScript:

var a = 0.2 + 0.4;

In most browser, we may have the value 0.600…0001. It is very anonying when we want to show a value with decimal point. There are a lot of methods to deal with it. We focus on round and parseFloat:

  1. Math.round(a * 10) / 10

  2. parseFloat(a.toFixed(1))

I believe that you will say method 1 has high performance. But how faster it has?

Please see the result here:

Centered Square Box in CSS

Published on September 07, 2019

How to Add a Web as Application at Windows?

Published on August 11, 2019