- Home
- projects
- tutorials
- about
- Website Services

This page was last updated on March 13th, 2020(UTC) and it is currently May 27th, 2022(UTC).

That means this page is 2 years, 75 days, 5 hours, 18 minutes and 17 seconds old. Please keep that in mind.

0b0000 = 0x00 = 0

0b0001 = 0x01 = 1

0b0010 = 0x02 = 2

0b0011 = 0x03 = 3

0b0100 = 0x04 = 4

0b0101 = 0x05 = 5

0b0110 = 0x06 = 6

0b0111 = 0x07 = 7

0b1000 = 0x08 = 8

0b1001 = 0x09 = 9

0b1010 = 0x0a = 10

0b1011 = 0x0b = 11

0b1100 = 0x0c = 12

0b1101 = 0x0d = 13

0b1110 = 0x0e = 14

0b1111 = 0x0f = 15

Two things should be fairly obvious at this point. Firstly, all odd numbers end with 1 in binary. Secondly, 1 hex digit is exactly 4 binary digits. This is where hex is useful. Let's say you had a 64bit (8 byte, where 8 bits make up a bite totally for 64 binary digits) number (CPUs at this time are 64bit) such as 0x7e84a4f4ff4a8909, which is ugly enough in hex, but now see it in binary: 0b0111,1110,1000,0100,0101,0100,1111,0100,1111,1111,0100,0101,1000,1001,0000,1001. Add to the fact that commas usually aren't allowed when making computer programs (as commas are already used to separate "parameters" of functions).

The best news yet is that, odds are, you're rarely going to directly use numbers that big. That said, converting 1 byte numbers is going to be useful. First, to figure out the range, you'll want to take 2 to the power of n, where n is the number of bits. Subtract 1 and that's your maximum positive range. For example, 2 to the power of 8 (8 bits in a byte) is 256, which gives us a range of 0 to 255. The value of each "bit" is similarly calculated: use the "offset" from the rightmost digit plus one as n, but don't subtract. So, the righmost digit is not "offset" at all, so it's 2 to the power of 0, which is 1. The digit once to the left has an offset of 1, so it's 2 to the power of 1, which is 2. The next digit to the left has an offset of 2, so it's 2 to the power of 2, which is 4. The next digit then is an offset of 3, so it's 2 to the power of 3, which is 8. Now, what you do, is you add the value of each binary digit if it's true, otherwise you don't. So if you have a number like 0b10010011, I'm going to add 1, 2, 16, and 127 together to get the value of 146. To get back to binary, you want to pick the biggest number that fits and go backwords and "turn the bits to true" as you go.

Too hard? That's OK, you can get away with cheating on this one, but I recommend you try to figure it out, anyay, even if you have to look it up somewhere else. It'll make things go a bit smoother over the course of the next couple lessons.

Get your own web kitty here!