- Notifications
You must be signed in to change notification settings - Fork179
Numbers#62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
tarasyyyk merged 6 commits intojavascript-tutorial:masterfromalexandrtovmach:translation/js-dataTypes-numberMar 6, 2020
Uh oh!
There was an error while loading.Please reload this page.
Merged
Numbers#62
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
2206ccf
feat: Completed half of article translation
alexandrtovmach92fc77f
Apply suggestions from code review
alexandrtovmachd669861
feat: Completed article translation
alexandrtovmachd94a3e3
feat: Completed tasks translation
alexandrtovmachc8d550d
Merge branch 'translation/js-dataTypes-number' of github.com:alexandr…
alexandrtovmach49766ed
Apply suggestions from code review
alexandrtovmachFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 4 additions & 4 deletions1-js/05-data-types/02-number/1-sum-interface/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
```js run demo | ||
let a = +prompt("Перше число?", ""); | ||
let b = +prompt("Друге число?", ""); | ||
alert( a + b ); | ||
``` | ||
Зверніть увагу на одиничний плюс`+`перед `prompt`.Це відразу перетворює значення в число. | ||
В іншому випадку, `a`і`b`будуть рядками, і в результаті вони об'єднаються (конкатинуються), тобто: `"1" + "2" = "12"`. |
6 changes: 3 additions & 3 deletions1-js/05-data-types/02-number/1-sum-interface/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
19 changes: 9 additions & 10 deletions1-js/05-data-types/02-number/2-why-rounded-down/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
Десятковий дріб`6.35`являє собою нескінченний двійковий код. Як завжди в таких випадках, він зберігається з втратою точності. | ||
Подивимось: | ||
alexandrtovmach marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
```js run | ||
alert( 6.35.toFixed(20) ); // 6.34999999999999964473 | ||
``` | ||
Втрата точності може спричинити як збільшення, так і зменшення числа. У цьому конкретному випадку число стає трохи меншим, тому воно округляється вниз. | ||
А що для `1.35`? | ||
```js run | ||
alert( 1.35.toFixed(20) ); // 1.35000000000000008882 | ||
``` | ||
Тут втрата точності зробила число трохи більшим, тому воно округляється вверх. | ||
**Як ми можемо виправити проблему з числом `6.35`, якщо хочемо, щоб воно було правильно округлене?** | ||
Ми повинні наблизити його до цілого числа до округлення: | ||
```js run | ||
alert( (6.35 * 10).toFixed(20) ); // 63.50000000000000000000 | ||
``` | ||
Зауважте, що `63.5`взагалі не має втрат на точність. Це тому, що десяткова частина `0.5`насправді є `1/2`.Дроби, розділені на`2`, точно представлені у двійковій системі, і ми можемо її округлити: | ||
```js run | ||
alert( Math.round(6.35 * 10) / 10); // 6.35 -> 63.5 -> 64(округлене) -> 6.4 | ||
``` | ||
10 changes: 5 additions & 5 deletions1-js/05-data-types/02-number/2-why-rounded-down/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion1-js/05-data-types/02-number/3-repeat-until-number/_js.view/solution.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions1-js/05-data-types/02-number/3-repeat-until-number/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions1-js/05-data-types/02-number/3-repeat-until-number/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions1-js/05-data-types/02-number/4-endless-loop-error/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions1-js/05-data-types/02-number/4-endless-loop-error/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions1-js/05-data-types/02-number/8-random-min-max/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions1-js/05-data-types/02-number/8-random-min-max/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions1-js/05-data-types/02-number/9-random-int-min-max/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions1-js/05-data-types/02-number/9-random-int-min-max/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.