'' Gnu compiler would complain: hey what you doing bro '' that really made my day
@wuza84055 жыл бұрын
I don't really know why youtube algorithm gives me videos with knowledge, that I need right now, thank you very much, it's essential with packet forming and even reading binary files, beautiful!
@nextlifeonearth3 жыл бұрын
Instead of using -1, I prefer to just invert the 0, to be more specific. ie: uint8_t data = ~0U; And remember; signed binary arithmetic is undefined behaviour.
@Morimea2 жыл бұрын
21:17 - wow I was looking for something like that in C++, new for me (float bit hacks... wow!) great video with lots of useful information!
@windcarve82655 жыл бұрын
Neat little things to use with bit fields! The problem for me was coming up with some use for them! Thanks for demonstrating some of the uses :) !
@calmsh0t5 жыл бұрын
thats a great demonstration, thanks!
@AegirAexx7 жыл бұрын
God dammit.. If I would've known about Bit Fields when I did my Computer Architecture course things would've been much easier. I was always cursing that I was unable to try out bit manipulation on odd number bits problems. This is great stuff. Your channel rocks!
@BarnardClangdeggin8 жыл бұрын
Nice tutorial. Good job.
@ColinBroderickMaths3 жыл бұрын
You said several times that other compilers might do it differently, but do you have any examples of compilers doing it differently?
@elliott81753 жыл бұрын
Sadly the use of *union* for type-punning, although supported by most compilers, isn't defined by the standard (it *_is_* for *C* , but not *C++* ). Have a look at stackoverflow's _"Accessing inactive union member and undefined behavior?"_
@konstantinrebrov6756 жыл бұрын
Amazing!
@AfdhalAtiffTan7 жыл бұрын
Thank you!
@noxatra60303 жыл бұрын
nice
@shritishaw75103 жыл бұрын
I didn't get the fact:- you wrote unsigned char a:3,b:3; and then in the main() you assigned bf.a = int type and so goes for bf.b. And then you told that it will support all kinds of arithmetic operations. Well, you're right. but data type of a and b is char and we are assigning int value to both of them in the main(). And to my surprise, the compiler doesn't show any error, instead, it displays the solution. HOW IS THIS HAPPENING?
@privateerburrows3 жыл бұрын
Automatic conversion of int to char. Just like you can write float f = 4.2, instead of float f = 4.2f if you're sloppy. I guess they could have made a special notation for bitfield constants, like 7:u3 or 11:i4 that are checked to make sense at compile time... =9:i3; //BOOM!