Skip to content

Commit a4bcdeb

Browse files
authored
Merge pull request rage#49 from rage/ljleppan-patch-5
Minor language changes, row -> line
2 parents fddac7c + ac673c6 commit a4bcdeb

1 file changed

Lines changed: 48 additions & 48 deletions

File tree

data/part-1/5-calculating.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ hidden: false
1818

1919
<!-- Laskuoperaatiot ovat tuttuja ja suoraviivaisia: yhteenlasku `+`, erotus `-`, kertolasku `*` ja jakolasku `/`. Laskentajärjestys on myös tuttu: laskenta tehdään vasemmalta oikealle sulut huomioon ottaen. Kuitenkin `*` ja `/` lasketaan ennen `+` ja `-` operaatioita, samoin kuin perus- tai kansakoulumatematiikassa on tullut tutuksi. -->
2020

21-
The basic mathematical operations are both familiar and straightforward: addition `+`, subtraction `-`, multiplication `*`, and division`/`. The precedence is also familiar: operations are performed from left to right with the parentheses taken into account. Expressions involving `*` and `/` are calculated before those involving `+` and `-`, as is customary in elementary school mathematics.
21+
The basic mathematical operations are both familiar and straightforward: addition `+`, subtraction `-`, multiplication `*`, and division `/`. The precedence is also familiar: operations are performed from left to right with the parentheses taken into account. Expressions involving `*` and `/` are calculated before those involving `+` and `-`, as is customary in elementary school mathematics.
2222

2323
<!-- ```java
2424
int eka = 2;
@@ -258,7 +258,7 @@ first + second;
258258
## Calculating and Printing
259259

260260
<!-- Muuttujan arvon voi tulostaa komennolla `System.out.println`. Tulostettavaan hipsuilla merkittyyn merkkijonoon, esim. "Pituus ", voidaan lisätä muuta tulostettavaa operaation `+` avulla. -->
261-
The command `System.out.println` prints the value of a variable. The string literal to be printed, which is marked by quotation marks, can be appended with the operation `+`.
261+
The command `System.out.println` prints the value of a variable. The string literal to be printed, which is marked by quotation marks, can be appended with other content by using the operation `+`.
262262

263263
<!-- ```java
264264
int pituus = 42;
@@ -653,7 +653,7 @@ Give the second number:
653653

654654
<!-- Kun olet saanut edellisen tehtävän toteutettua, kokeile mikä on suurin mahdollinen kertolasku minkä saat laskettua. Huomaamasi ilmiön taustalla on se, että kokonaislukumuuttujan arvo voi olla korkeintaan 2<sup>31</sup>-1 eli 2147483647. Tämä johtuu siitä, että kokonaislukumuuttujat esitetään tietokoneen muistissa 32 bitin avulla. Tähän tutustutaan tarkemmin muunmuassa kurssilla Tietokoneen toiminta. -->
655655

656-
Once you have completed the previous exercise, try finding out the greatest possible multiplication that you can calculate. The reason behind the phenomenon you've observed is that the value of an integer value is capped at the maximum of 2<sup>31</sup>-1 (i.e. 2147483647). This is because integer variables are represented with 32 bits in the computer's memory. Variable representation is covered in more detail on the Computer Organization course.
656+
Once you have completed the previous exercise, try finding out the greatest possible multiplication that you can calculate. The reason behind the phenomenon you'll observe is that the value of an integer value is capped at the maximum of 2<sup>31</sup>-1 (i.e. 2147483647). This is because integer variables are represented with 32 bits in the computer's memory. Variable representation is covered in more detail on the Computer Organization course.
657657

658658

659659
<!-- ## Jakolasku -->
@@ -843,7 +843,7 @@ An average refers to the sum of numbers divided by their count. For instance, th
843843

844844
<!-- Ohjelmoinnissa tähän liittyy muutamia asioita, jotka tulee muistaa. Ensiksi, nollalla jakaminen ei tyypillisesti ole sallittua. Tämä tarkoittaa sitä, että nollan luvun keskiarvon laskeminen ei onnistu. Toiseksi, mikäli ohjelma käsittelee lukujen lukumäärän ja summan kokonaislukumuuttujina, tulee muuttujista jompikumpi (tai kummatkin) muuntaa liukulukumuuttujaksi kertomalla luku arvolla 1.0 ennen jakolaskua. -->
845845

846-
In the context of programming, there are a few things to keep in mind. Firstly, dividing by zero is typically not permitted. This implies that calculating the average of the number zero is impossible. Secondly, if the program handles both the sum of the numbers and their total count as integers, one (or both) of the variables should be casted to a floating-point number by multiplying it by 1.0 before the division.
846+
In the context of programming, there are a few things to keep in mind. Firstly, dividing by zero is typically not permitted. This implies that calculating the average of zero numbers is impossible. Secondly, if the program handles both the sum of the numbers and their total count as integers, one (or both) of the variables should be casted to a floating-point number by multiplying it by 1.0 before the division.
847847

848848
</text-box>
849849

@@ -1011,19 +1011,19 @@ It's crucial for a programmer to understand that assigning a value to a variable
10111011

10121012
<!-- Kolme yleistä väärinkäsitystä, jotka liittyvät muuttujan arvon asettamiseen ovat seuraavat: -->
10131013

1014-
Here's three common misunderstanding related to assigning a value to a variable:
1014+
Here's three common misunderstandings related to assigning a value to a variable:
10151015

10161016
<!-- * Muuttujan asettamisen näkeminen siirtona kopioimisen sijaan: ohjelmakoodin `eka = toka` suorituksen jälkeen ajatellaan, että muuttujan `toka` arvo on siirtynyt muuttujan `eka` arvoksi, jonka jälkeen muuttujalla `toka` ei ole enää arvoa, tai sen arvo on esimerkiksi nolla. Tämä ei pidä paikkansa, sillä ohjelmakoodin `eka = toka` suorituksessa muuttujan `toka` nimeämässä paikassa oleva arvo kopioidaan muuttujan `eka` nimeämään paikkaan. Muuttujan `toka` arvo ei siis muutu. -->
10171017

1018-
* Viewing value assignment as a transfer instead of a copy operation: once `first = second` has been executed, it's often assumed that the value of the variable `second` has been moved to the value of the variable `first`, and that the variable `second` no longer holds a value, or that its value is 0, for instance. This is incorrect, as executing `first = second` means that the value in the position specified by `second` is merely copied to the place specified by the variable `first`. Hence, the variable `second` is not modified.
1018+
* Viewing value assignment as a transfer instead of a copy operation: once `first = second` has been executed, it's often assumed that the value of the variable `second` has been moved to the value of the variable `first`, and that the variable `second` no longer holds a value, or that its value is 0, for instance. This is incorrect, as executing `first = second` means that the value in the position specified by `second` is merely copied to the place specified by the variable `first`. Hence, the variable `second` is not modified.
10191019

10201020
<!-- * Muuttujan asettamisen näkeminen riippuvuutena kopioimisen sijaan: ohjelmakoodin `eka = toka` suorituksen jälkeen ajatellaan, että mikä tahansa muutos muuttujaan `toka` vaikuttaa automaattisesti myös muuttujaan `eka`. Tämä ei pidä paikkansa, sillä asetus -- kopiointi -- on yksittäinen tapahtuma. Se tapahtuu vain silloin, kun ohjelmakoodi `eka = toka` suoritetaan. -->
10211021

10221022
* Viewing value assignment as creating a dependency instead of being a copy operation: once `first = second` has been executed, it's often assumed that any change in the value of the variable `second` is automatically also reflected in the value of the variable `first`. This is incorrect; assignment -- i.e., copying -- is a one-off event. It only occurs when the program code `first = second` is executed.
10231023

10241024
<!-- * Kolmas väärinkäsitys liittyy kopioimisen suuntaan: ohjelmakoodin `eka = toka` suorituksessa ajatellaan, että muuttujan `toka` arvoksi kopioidaan muuttujan `eka` arvo. Tämä näkyy myös tilanteina, missä ohjelmoija voi vahingossa kirjoittaa esimerkiksi `42 = arvo` -- onneksi ohjelmointiympäristöt tukevat myös tässä. -->
10251025

1026-
* The third misunderstanding concerns the direction of copying: it's often thought that in executing `first = second` the value of the variable `first` is set as the value of the variable `second`. The confusion also manifests itself in situations where the programmer accidentally writes e.g. `42 = value -- fortunately, IDEs provide support on this issue too.
1026+
* The third misunderstanding concerns the direction of copying: it's often thought that in executing `first = second` the value of the variable `first` is set as the value of the variable `second`. The confusion also manifests itself in situations where the programmer accidentally writes e.g. `42 = value` -- fortunately, IDEs provide support on this issue too.
10271027

10281028
<!-- Ehkäpä paras tapa tietokoneen ohjelmakoodin suorittamisen ymmärtämiseen on paperin ja kynän käyttäminen. Kun luet ohjelmakoodia, kirjoita paperille uusien muuttujien nimet, sekä kirjoita ylös rivi riviltä, miten ohjelmakoodissa olevien muuttujien arvot muuttuvat. Havainnollistetaan suoritusta seuraavalla ohjelmakoodilla: -->
10291029

@@ -1042,15 +1042,15 @@ rivi 9: System.out.println(kolmas);
10421042
``` -->
10431043

10441044
```java
1045-
row 1: int first = (1 + 1);
1046-
row 2: int second = first + 3 * (2 + 5);
1047-
row 3:
1048-
row 4: first = 5;
1049-
row 5:
1050-
row 6: int third = first + second;
1051-
row 7: System.out.println(first);
1052-
row 8: System.out.println(second);
1053-
row 9: System.out.println(third);
1045+
line 1: int first = (1 + 1);
1046+
line 2: int second = first + 3 * (2 + 5);
1047+
line 3:
1048+
line 4: first = 5;
1049+
line 5:
1050+
line 6: int third = first + second;
1051+
line 7: System.out.println(first);
1052+
line 8: System.out.println(second);
1053+
line 9: System.out.println(third);
10541054
```
10551055

10561056
<!-- Alla on kirjoitettu yllä olevan ohjelmakoodin suoritus auki. -->
@@ -1096,38 +1096,38 @@ rivi 9: tulostetaan arvo 28
10961096

10971097
<sample-output>
10981098

1099-
row 1: initiate a variable first
1100-
row 1: copy the result of the calculation 1 + 1 as the value of the variable first
1101-
row 1: the value of the variable first is 2
1102-
row 2: create the variable second
1103-
row 2: calculate 2 + 5, 2 + 5 -> 7
1104-
row 2: calculate 3 * 7, 3 * 7 -> 21
1105-
row 2: calculate first + 21
1106-
row 2: copy the value of the variable first into the calculation, its value is 2
1107-
row 2: calculate 2 + 21, 2 + 21 -> 23
1108-
row 2: copy 23 to the value of the variable second
1109-
row 2: the value of the variable second is 23
1110-
row 3: (empty, do nothing)
1111-
row 4: copy 5 to the value of the variable first
1112-
row 4: the value of the variable first is 5
1113-
row 5: (empty, do nothing)
1114-
row 6: create variable third
1115-
row 6: calculate first + second
1116-
row 6: copy the value of the variable first into the calculation, its value is 5
1117-
row 6: calculate 5 + second
1118-
row 6: copy the value of the variable second into the calculation, its value is 23
1119-
row 6: calculate 5 + 23 -> 28
1120-
row 6: copy 28 to the value of the variable third
1121-
row 6: the value of the variable third is 28
1122-
row 7: print the variable first
1123-
row 7: copy the value of the variable first for the print operation, its value is 5
1124-
row 7: print the value 5
1125-
row 8: print the variable second
1126-
row 8: copy the value of the variable second for the print operation, its value is 23
1127-
row 8: print the value 23
1128-
row 9: print the variable third
1129-
row 9: copy the value of the variable third for the print operation, its value is 28
1130-
row 9: we print the value 28
1099+
line 1: initiate a variable first
1100+
line 1: copy the result of the calculation 1 + 1 as the value of the variable first
1101+
line 1: the value of the variable first is 2
1102+
line 2: create the variable second
1103+
line 2: calculate 2 + 5, 2 + 5 -> 7
1104+
line 2: calculate 3 * 7, 3 * 7 -> 21
1105+
line 2: calculate first + 21
1106+
line 2: copy the value of the variable first into the calculation, its value is 2
1107+
line 2: calculate 2 + 21, 2 + 21 -> 23
1108+
line 2: copy 23 to the value of the variable second
1109+
line 2: the value of the variable second is 23
1110+
line 3: (empty, do nothing)
1111+
line 4: copy 5 to the value of the variable first
1112+
line 4: the value of the variable first is 5
1113+
line 5: (empty, do nothing)
1114+
line 6: create variable third
1115+
line 6: calculate first + second
1116+
line 6: copy the value of the variable first into the calculation, its value is 5
1117+
line 6: calculate 5 + second
1118+
line 6: copy the value of the variable second into the calculation, its value is 23
1119+
line 6: calculate 5 + 23 -> 28
1120+
line 6: copy 28 to the value of the variable third
1121+
line 6: the value of the variable third is 28
1122+
line 7: print the variable first
1123+
line 7: copy the value of the variable first for the print operation, its value is 5
1124+
line 7: print the value 5
1125+
line 8: print the variable second
1126+
line 8: copy the value of the variable second for the print operation, its value is 23
1127+
line 8: print the value 23
1128+
line 9: print the variable third
1129+
line 9: copy the value of the variable third for the print operation, its value is 28
1130+
line 9: we print the value 28
11311131

11321132
</sample-output>
11331133

0 commit comments

Comments
 (0)