Skip to content

Commit 07635dd

Browse files
authored
Fix example on Operator Precedance #16 (#17)
1 parent 98f8654 commit 07635dd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/integers/operator_precedence.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ None of this should be a surprise if you learned [PEMDAS](https://www.khanacadem
1010

1111
```java
1212
// Following the order of operations:
13+
// 2 * 3 + 3 * 9 / 2 - 2
1314

1415
// 2 * 3 happens first
1516
// 6 + 3 * 9 / 2 - 2
@@ -18,11 +19,12 @@ None of this should be a surprise if you learned [PEMDAS](https://www.khanacadem
1819
// 6 + 27 / 2 - 2
1920

2021
// 27 / 2 happens next
21-
// because of int division, that gives 13
22+
// because of int division, that gives 13
23+
// (ignores float point number .5)
2224
// 6 + 13 - 2
2325

2426
// 6 + 13 comes next
25-
// 19 - 7
27+
// 19 - 2
2628

2729
// and the final result is 17;
2830
int result = 2 * 3 + 3 * 9 / 2 - 2;

0 commit comments

Comments
 (0)