Counting in Binary and Hexadecimal. - Printable Version +- Makestation (https://makestation.net) +-- Forum: Technical Arts (https://makestation.net/forumdisplay.php?fid=45) +--- Forum: Technology & Hardware (https://makestation.net/forumdisplay.php?fid=29) +---- Forum: Resources & Tutorials (https://makestation.net/forumdisplay.php?fid=132) +---- Thread: Counting in Binary and Hexadecimal. (/showthread.php?tid=3837) |
Counting in Binary and Hexadecimal. - SpookyZalost - March 21st, 2024 Boring as this may sound the following information is actually on the Network+ certification exam (but not the A+ interestingly enough.) So to that end, the following is a simple how-to on 8bit computer math. for 16 bit 32bit and 64 bit you simply scale up. To start with, what is binary math? Well binary is simply counting with switches in an on/off state. first 4 places go like this. 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = 10 1011 = 11 1100 = 12 1101 = 13 1110 = 14 1111 = 15 and so on. next would be 10000 = 16 And thus it scales like that. You can count quickly on your fingers too on your hands starting from right to left you lift each finger to represent an on or off state. 10 would be closed pinkie, lifted ring finger, closed middle finger, lifted forefinger. 9 would be basically the devil horns metal heads are so fond of. 17 is basically the hang loose hand sign. as it's 10001 why this is will become apparent pretty quickly when you realize that each digit represents a doubling of the previous, so it goes like this. 1 2 4 8 16 32 64 128 256 if those numbers sound familiar it's because we use them to measure everything from hard drive size to ram size. so an 8 bit integer can represent everything from 0 to 255 for a total of 256 digits including 0, with 256 being the 9th bit where you get into 16 bit binary computation. Hex is a similar case. it's an 8 bit integer but instead of a string of 8 bits it's represented by 2, 4 bit hex numbers put together and goes something like this. 0 1 2 3 4 5 6 7 8 9 A B C D E F This can be converted to binary as well. 0000 = 0 0001 = 1 0010 = 2 0011 = 3 0100 = 4 0101 = 5 0110 = 6 0111 = 7 1000 = 8 1001 = 9 1010 = A 1011 = B 1100 = C 1101 = D 1110 = E 1111 = F so converting that you get an 8 bit integer with two hex numbers (Yes the letters technically represent numbers, it's base 16) so 18 in hex would convert to 00011000 in binary. which would convert to decimal as 1 2 4 8 16 32 64 128 256 0 0 0 1 1 0 0 0 0 or 8+16 = 24. and that's the core of computer math right there. it's just strings of numbers representing on/off state switches that get added together to get decimal numbers, and hex is just a way to simplify those long strings into pairs representing half of an 8 bit byte. so let's look at the hex color code. FFFFFF is the color white. but it comes out in binary as all 1's. 11111111 11111111 11111111 that is a 32 bit integer. which comes down to 1 2 4 8 16 32 64 128 256 (8bit) 512 1024 2048 4096 8192 16384 32768 65536 (16 bit) 131072 262144 524288 1,048,576 2,097,152 4,194,304 8,388,608 16,777,216 so FFFFFF is equal to 16,777,215 in decimal or 11111111 11111111 11111111 but it's easier to just write FF:FF:FF and if you recognize that format, that's because mac addresses are 8 bit integers written as hex pairs for a total of 6 pairs for example 18:AC:22:14:16:AA that's 8 16 24 32 64 128 creating literally billions of combinations with a 128 bit integer converted to hex and broken down into binary by a computer, give it a try some time. if you convert a hex address to decimal, you get the unique identification number which will be a long string of binary if you convert it the other way. This also goes into IP addresses and addressing for both IPV4 and IPV6 which I will cover in another article. - Z |