Eli5 Binary and hexadecimals

204 views

I’m struggling in class with understanding and calculating😭😭 It’s just not clicking for me

In: 6

9 Answers

Anonymous 0 Comments

There’s other good answers about the system itself, so I’ll focus on the ‘calculating’ part of the question (sorry if I misinterpret what you are asking).

The math you already know works pretty well with other number systems. 1*n = n, 0*n = 0. 10*10 = 100. It’s just the in betweens that might trip you up, but if you don’t need to solve in the fewest amount of steps you can just convert the numbers into something that makes sense to you.

Here’s a simple example: in binary, 0b10 represents 2 (the leading 0b tells everybody the rest of the number is **B**inary, which is important if you want to switch back and forth). So 0b10*0b10 converted to decimal is 2*2, or 4. And the answer you would have had if you stayed in binary, 0b100, is the correct conversion for 4.

This also works with more complex numbers:

* 0b101*0b101 =
* 0b101(0b100 + 0b1) =
* 0b101*0b100 + 0b101*0b1 =
* 0b10100+0b101 =
* 0b11001
* or 5*5 = 25, which converts back to 0b11001.

Hexidecimal can be intimidating, and generally not worth trying to calculate by hand without converting to decimal; we needed memorizing times tables in order to get it done with decimal, and practically nobody is willing to do that when we have computers everywhere anyway. If you need to multiply 0xB*0xB, you might as well change it to 11*11 = 121 = 0x79, or 7*16+9 (the leading 0x means he**X**idecimal).

The only shorthand I can give you for hex calculations is that 0x8 is like decimal’s 5, and 0x4 is kind of similar to even numbers: multiplying by 0x8 will always result in a 0x…8 or a 0x…0, while 0x4 will always result in 0x…0, 0x…4, 0x…8, or 0x…C. These two facts are used in 4-byte or 8-byte address locations and accessing them, but that’s a programming thing.

You are viewing 1 out of 9 answers, click here to view all answers.