Invitation to Cybersecurity

INVITATION TO CYBERSECURITY 12 2.1.3 Binary “There are only 10 types of people in the world: those who understand binary and those who don’t.” - A computer geek joke Because digital computers operate only on binary signals, they use a binary, or base two, number system. We are more familiar with our decimal, or base ten, number system that uses ten distinct symbols [0-9], but the two systems are mathematically equivalent. In base ten, each decimal place is a power of ten, so there is the ones place (10⁰), tens place (101), hundreds place (102), thousands place (103), etc. In base two, each binary place is a power of two, so there is the ones place (20), twos place (21), fours place (22), eights place (23), etc. To distinguish binary numbers from base ten numbers the prefix 0b is sometimes used. The binary value 0b10 has 1 two and 0 ones so its decimal value is two: (1 x 2) + (0 x 1) = 2 Here again 10 is not equal to the number of fingers on two hands! The byte 0b01100100 has 0 one hundred twenty-eights, 1 sixty-four, 1 thirty-two, 0 sixteens, 0 eights, 1 four, 0 twos and 0 ones. Add up all these values, and its decimal value is 100: (0 x 128) + (1 x 64) + (1 x 32) + (0 x 16) + (0 x 8) + (1 x 4) + (0 x 2) + (0 x 1) = 0 + 64 + 32 + 0 + 0 + 4 + 0 + 0 = 100 A byte can range between 0b00000000 (0 in decimal) to 0b11111111 (255 in decimal). Any base two number can be converted to a base ten number using this approach. Of course, base ten numbers can also be converted to base two numbers, but base ten numbers with decimal points can be tricky—these are called floating point numbers in computing and are too advanced for this text! 210 bytes are a kilobyte (KB), 220 are a megabyte (MB), and 230 are a gigabyte (GB).3 The Greek prefixes are used because these numbers are similar in magnitude to thousands (kilo), millions (mega), and billions (giga) in the base ten number system. This simple mapping between powers of two and powers of ten holds and can be used to approximate the order of magnitude of base two numbers (see Table 2.3). The base two-base ten conversion rule states that ten binary places are approximately equal to three decimal places. 3 Unfortunately, these terms are ambiguous and in some contexts do refer to powers of ten instead of powers of two—you have to examine the fine print to determine which system is being used.

RkJQdWJsaXNoZXIy MTM4ODY=