translate
This commit is contained in:
parent
811a6c7920
commit
98c987e794
84 changed files with 826 additions and 880 deletions
|
@ -1,13 +1,17 @@
|
|||
Потому что `i` никогда не станет равным `10`.
|
||||
That's because `i` would never equal `10`.
|
||||
|
||||
Запустите, чтобы увидеть *реальные* значения `i`:
|
||||
Run it to see the *real* values of `i`:
|
||||
|
||||
```js run
|
||||
var i = 0;
|
||||
let i = 0;
|
||||
while (i < 11) {
|
||||
i += 0.2;
|
||||
if (i > 9.8 && i < 10.2) alert( i );
|
||||
}
|
||||
```
|
||||
|
||||
Ни одно из них в точности не равно `10`.
|
||||
None of them is exactly `10`.
|
||||
|
||||
Such things happen because of the precision losses when adding fractions like `0.2`.
|
||||
|
||||
Conclusion: evade equality checks when working with decimal fractions.
|
|
@ -2,12 +2,12 @@ importance: 4
|
|||
|
||||
---
|
||||
|
||||
# Бесконечный цикл по ошибке
|
||||
# An occasional infinite loop
|
||||
|
||||
Этот цикл - бесконечный. Почему?
|
||||
This loop is infinite. It never ends. Why?
|
||||
|
||||
```js
|
||||
var i = 0;
|
||||
let i = 0;
|
||||
while (i != 10) {
|
||||
i += 0.2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue