Because JavaScript uses the IEEE 754 standard for Math, it makes use of 64-bit floating numbers. This causes precision errors when doing floating point (decimal) calculations, in short, due to computers working in Base 2 while decimal is Base 10.

```
0.1 + 0.2; // 0.300000004
```

A simple solution to this problem is:

```
+(0.1 + 0.2).toFixed(1); // 0.3
```

Here the numbers are added together, returning the erroneous floating number, it is then set using `toFixed`

as a string `"0.3"`

. Finally the `+`

symbol casts the string back to a valid `Number`

so that it can be worked with again.

```
var x = 0.1,
y = 0.2;
var z = +(x + y).toFixed(1);
z += 0.1; // z is now 0.4
```