►C Programming playlist: [ Ссылка ]
►Find full courses on: [ Ссылка ]
►Join as member to get perks: [ Ссылка ]
►Lesson Description: In this lessons I show you some bit manipulation techniques in C. I first will show you the left and right shift operators as a technique for multiplying and dividing. It also turns out that if you are multiplying and dividing by two, this can be a simpler instruction and quick optimization in your code. Once you know how to bit shift, you can also compacting move information inside of data type as well, so I will also show you how we can pack information into a pixel.
In the next part of the lesson, I show you how to create a bit field, and why it is more efficient than using data types in a struct. This can again be another large optimization for saving space.
One thing NOT discussed in the video however, is when to make these kinds of optimizations and use these tricks. It's probably worth noting that you should only optimize when you know you need more performance--at least when you are first learning how to program. That said, now you know these techniques exist!
00:00 Introduction
00:40 Bit shifting introduction
2:42 Bit shifting (left shift) example code for multiplication
4:18 right shift operation for division
6:00 Packing data into an integer
15:18 Bit fields motivating example
18:05 Experimenting with struct sizes
23:49 Conclusion
►Please like and subscribe to help the channel!
►YouTube Channel: [ Ссылка ]
►Join our free community: [ Ссылка ]
Ещё видео!