Hello everyone! Today we'll look at the the 2's complement(or two's complement for long), that I didn't really explain in the post about dates. So, what is it? Its a method of storing signed integers(of 2+bit size). And, how is it useful? First, lets start with how it works. Twos complement is just like normal binary in the positives(-1bit for the sign), but it gets interesting when we get to the negatvies. So, 10 for example, is 8 + 2 = 0b00001010. Now, theres also -10, and you might think thats 0b10001010, flipper first bit for it being negative, but in 2s complement its actually: 0b11110101. Thats because each bit gets flipped when turning into negatives, allowing few mildly interesting things. First, its easier to flip the integer. Not from the view of clock cycles, but rather code niceness. To flip it into positive normally, you would propably want to flip the first bit like so: & 0x1 << 8, or similiar. To make the twos complement number negative, you just do ~(A << 1(something like that)) or something similiar, and it will convert. This is not the best thing about it tho, and actually preety unimportant one, so lets go over the more important ones! Extended capacity by 1 for negatives. Since there is 0 but not -0, twos complement is implemented in a way that 0b1111 is actually -1, 0b1110 is -2, etc. Which allows (for 8bit example) the capacity from -128 to 127. And now the main one, mathematics with negative numbers. Letme show you an example: -60 + 4 is(in 2's complement) First, 60 = 0b00111100, so -60 = 0b11000100, 4 = 0b00000100 and 0b11000100 +0b00000100 = 0b11001000 + 1 0b00111000 = 8 + 16 + 32 = 56! This way, everything can be done like if it was normal unsigned int, except you're working with signed numbers. And the disadvantage? Well, that 0b0000 lets say when it gets to 7, and then 1 will be added, it will turn into 0b1000, therefore -16, instead of zero. That will be all for today, see you soon!