Difference between revisions of "Intermediate C++ Game Programming Tutorial 23"
From Chilipedia
(→Video Timestamp Index) |
(→Video Timestamp Index) |
||
Line 16: | Line 16: | ||
** Biswise OR (|): 1010 | 1100 = 1110, also called a mash | ** Biswise OR (|): 1010 | 1100 = 1110, also called a mash | ||
* Shifting operations [https://youtu.be/WPMwq0qM8Kk?t=5m10s 5:10] | * Shifting operations [https://youtu.be/WPMwq0qM8Kk?t=5m10s 5:10] | ||
+ | ** Shift left (<<): 0011 << 1 = 0110 | ||
== Homework == | == Homework == |
Revision as of 05:24, 26 November 2019
Bit twiddling is a lot of bullshit that is usually avoided when possible because it leads to ass code. Still, it is necessary in various situations, so you gotta learn this shit, and now is as good a time as any I guess.
Topics Covered
- Bitwise AND (&), OR (|), and shift left/right (>> and <<)
- Unary bitwise NOT/complement (~) and bitwise XOR (^)
- Masking with & and combining with |
- Packing and unpacking smaller data in larger types
- Bit flags
- Bitwise arithmetic optimizations
Video Timestamp Index
- Introduce
std::string ToBin(unsigned int n, int min_digits=0);
to convert integers to their binary representation 0:15 - Bitwise operators 1:50
- Biswise AND (&): 1010 & 1100 = 1000, also called a mask
- Biswise OR (|): 1010 | 1100 = 1110, also called a mash
- Shifting operations 5:10
- Shift left (<<): 0011 << 1 = 0110
Homework
- Figure out how the binary string formatter routine works
- Figure out why
x % 16
compiles tox & 0xF
The solution for the problems will not have its own video. Feel free to come on the discord and compare your answers with others, or to ask specific questions if you are having trouble understanding.