Skip to content

Commit 6044e1a

Browse files
committed
Change Math methods to correct ones
1 parent 8e558e5 commit 6044e1a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

chapter-08-exam-preparation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ We calculate how many **bricks** the workers transport in a single course.
121121

122122
![](assets/chapter-8-1-images/02.Bricks-02.png)
123123

124-
By dividing the total number of **bricks transported for 1 course**, we will obtain the number of **courses** required to carry them. We have to consider that when dividing whole numbers, the remainder is ignored and always rounded down. To avoid this, we will convert the right side of the equation to **`double`** and use the **`Math.Ceiling(…)`** function to round the result always up. When the bricks can be transferred with **an exact number of courses**, the division will return a whole number and there will be nothing to round. Accordingly, if not, the result of the division will be **the number of exact courses** but a decimal fraction. The decimal part will be rounded up and we will get the required **1 course** for the remaining bricks.
124+
By dividing the total number of **bricks transported for 1 course**, we will obtain the number of **courses** required to carry them. We have to consider that when dividing whole numbers, the remainder is ignored and always rounded down. To avoid this, we will convert the right side of the equation to **`double`** and use the **`Math.ceiling(…)`** function to round the result always up. When the bricks can be transferred with **an exact number of courses**, the division will return a whole number and there will be nothing to round. Accordingly, if not, the result of the division will be **the number of exact courses** but a decimal fraction. The decimal part will be rounded up and we will get the required **1 course** for the remaining bricks.
125125

126126
![](assets/chapter-8-1-images/02.Bricks-03.png)
127127

@@ -177,13 +177,13 @@ We read the input from the console.
177177

178178
![](assets/chapter-8-1-images/03.Point-on-segment-04.png)
179179

180-
Since we do not know which **point** is on the left and which is on the right, we will create two variables to mark this. Since the **left point** is always the one with the smaller **x coordinate**, we will use **`Math.Min(…)`** to find it. Accordingly, **the right one** is always the one with a larger **x coordinate** and we will use **`Math.Max(…)`**. We will also find the distance from **point x** to **the two points**. Because we do not know their position relative to each other, we will use **`Math.Abs(…)`** to get a positive result.
180+
Since we do not know which **point** is on the left and which is on the right, we will create two variables to mark this. Since the **left point** is always the one with the smaller **x coordinate**, we will use **`Math.min(…)`** to find it. Accordingly, **the right one** is always the one with a larger **x coordinate** and we will use **`Math.max(…)`**. We will also find the distance from **point x** to **the two points**. Because we do not know their position relative to each other, we will use **`Math.abs(…)`** to get a positive result.
181181

182182
![](assets/chapter-8-1-images/03.Point-on-segment-05.png)
183183

184184
![](assets/chapter-8-1-images/03.Point-on-segment-06.png)
185185

186-
The shorter of the two **distances** we can find using **`Math.Min(…)`**.
186+
The shorter of the two **distances** we can find using **`Math.min(…)`**.
187187

188188
![](assets/chapter-8-1-images/03.Point-on-segment-07.png)
189189

0 commit comments

Comments
 (0)