Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Week-1/01-Syntax-IO/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,16 @@ Arithmetic and comparison operators are identical across all three. Key differen

Bitwise operators (`&`, `|`, `^`, `<<`, `>>`) have identical syntax in all three. Two patterns you will use constantly in DSA:

**C++ and Java**
**C++**
```cpp
if (x & 1) // true if x is odd - faster than x % 2 == 1
if (x & 1) // true if x is odd (any non-zero integer treated as true) - faster than x % 2 == 1
x = x << 1; // multiply by 2
x = x >> 1; // integer divide by 2
```

**Java**
```java
if((x & 1) != 0 ) // true if x is odd (no implicit conversion from int to boolean unlike c++)
x = x << 1; // multiply by 2
x = x >> 1; // integer divide by 2
```
Expand Down