Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 741d90c

Browse files
committed
minor fixes
1 parent 6edb240 commit 741d90c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎1-js/05-data-types/02-number/article.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ Strange! What is it then if not `0.3`?
213213
alert( 0.1 + 0.2 ); // 0.30000000000000004
214214
```
215215

216-
Ouch! There are more consequences than an incorrect comparison here. Imagine you're making an e-shopping site and the visitor puts `0ドル.10` and `0ドル.20` goods into their cart. The order total will be `0ドル.30000000000000004`. That would surprise anyone.
216+
Ouch! Imagine you're making an e-shopping site and the visitor puts `0ドル.10` and `0ドル.20` goods into their cart. The order total will be `0ドル.30000000000000004`. That would surprise anyone.
217217

218218
But why does this happen?
219219

220220
A number is stored in memory in its binary form, a sequence of bits - ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form.
221221

222-
In other words, what is `0.1`? It is one divided by ten `1/10`, one-tenth. In decimal numeral system such numbers are easily representable. Compare it to one-third: `1/3`. It becomes an endless fraction `0.33333(3)`.
222+
What is `0.1`? It is one divided by ten `1/10`, one-tenth. In decimal numeral system such numbers are easily representable. Compare it to one-third: `1/3`. It becomes an endless fraction `0.33333(3)`.
223223

224224
So, division by powers `10` is guaranteed to work well in the decimal system, but division by `3` is not. For the same reason, in the binary numeral system, the division by powers of `2` is guaranteed to work, but `1/10` becomes an endless binary fraction.
225225

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /