+ 4
Any c sharp developers ever use << ? If so, why?
3 Answers
+ 9
Imagine you have an 8x8 chessboard, and you want to store where on the board team white has placed their pawns.
That would be 64 squares, each containing 1 bit of information (yes/no).
So a single 64-bit integer can store everything you need, which saves a lot of space and time compared to an array. To retrieve a single square you need bitwise operators like <<, >>, |, &.
This is called a "bitboard" and is common when developing AI for board games.
+ 7
Here, see which one is simpler?
https://code.sololearn.com/c4as5YQ66Qlc/?ref=app
Edit: And the time difference
https://code.sololearn.com/c99w8q0hh6VM/?ref=app
+ 2
Yes, itâs the bitwise left shift operator. https://www.sololearn.com/learn/4087/