Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

New questions #1

Merged
merged 19 commits into from
May 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add question floating-point
  • Loading branch information
fejes713 committed May 2, 2018
commit 652be1356ad50c1de0c550aa6b0f452c98774175
19 changes: 19 additions & 0 deletions questions/floating-point.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### What does `0.1 + 0.2 === 0.3` return?

#### Answer

It equals to `false` because JavaScript uses the IEEE 754 standard for Math and it makes use of 64-bit floating numbers. This causes precision errors when doing decimal calculations, in short, due to computers working in Base 2 while decimal is Base 10

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

#### Aditional links

* [Fix "0.1 + 0.2 = 0.300000004" in JavaScript](http://blog.blakesimpson.co.uk/read/61-fix-0-1-0-2-0-300000004-in-javascript)

#### Good to hear

* A simple solution to this problem

<!-- tags: (javascript) -->