Please Whitelist This Site?

I know everyone hates ads. But please understand that I am providing premium content for free that takes hundreds of hours of time to research and write. I don't want to go to a pay-only model like some sites, but when more and more people block ads, I end up working for free. And I have a family to support, just like you. :)

If you like The TCP/IP Guide, please consider the download version. It's priced very economically and you can read all of it in a convenient format without ads.

If you want to use this site for free, I'd be grateful if you could add the site to the whitelist for Adblock. To do so, just open the Adblock menu and select "Disable on tcpipguide.com". Or go to the Tools menu and select "Adblock Plus Preferences...". Then click "Add Filter..." at the bottom, and add this string: "@@||tcpipguide.com^$document". Then just click OK.

Thanks for your understanding!

Sincerely, Charles Kozierok
Author and Publisher, The TCP/IP Guide


NOTE: Using software to mass-download the site degrades the server and is prohibited.
If you want to read The TCP/IP Guide offline, please consider licensing it. Thank you.

The Book is Here... and Now On Sale!

Read offline with no ads or diagram watermarks!
The TCP/IP Guide

Custom Search







Table Of Contents  The TCP/IP Guide
 9  Networking Fundamentals
      9  Backgrounder: Data Representation and the Mathematics of Computing

Previous Topic/Section
Binary Information and Representation: Bits, Bytes, Nibbles, Octets and Characters
Previous Page
Pages in Current Topic/Section
1
23
Next Page
Decimal, Binary, Octal and Hexadecimal Number Conversion
Next Topic/Section

Decimal, Binary, Octal and Hexadecimal Numbers
(Page 1 of 3)

The numbers we are used to using in every-day life are called decimal numbers, where the word “decimal” refers to the number ten. The reason for this is rather obvious: every digit can take on one of ten values: 0 to 9. Arithmetic performed on decimal numbers is also called base 10 mathematics, because of this orientation around the number 10. (Why is the number 10 the foundation of our normal mathematical system? Hold both hands up and count…)

Computer systems, however, don’t have fingers or toes; they deal only with binary numbers. Each bit can represent not a value from 0 to 9, but from, well, 0 to 1. A single “0 or 1” value is sufficient for encoding a single fact, such as whether your car currently is using summer tires or snow tires. It's not nearly enough to hold more complex information, such as your bank account balance, or a text document, or a picture of the Yellowstone canyon.

Binary Numbers and their Decimal Equivalents

For this reason, larger collections of bits have been defined by computer scientists, such as bytes (octets), words, and so forth. When individual bits are collected into sets in this way, they can be used together to represent larger integers, which are called binary numbers. Since there are only two possible values for each digit, binary numbers are also called base 2 numbers.

A lot of people are intimidated by binary numbers, because at first they seem quite confusing. The key to understanding them is realizing that they are exactly the same as decimal numbers, except that instead of each digit having a value in the range of 0 to 9, each has a value in the range of 0 to 1. For example, when you count in decimal, you go up to 9 in the one’s place, and then you need a second place for “tens”. If you go above 99, you need a third place for “hundreds”. Each additional place added on the left is a higher power of ten. Binary is the same, except the limit for each place is 1 instead of 9. In binary, you go up to 1 in the one’s place, and then need a second place for “twos”. If you go above 3, you need a third place for “fours”. Each added place is a subsequent higher power of two, rather than ten.

Thus, where counting in decimal goes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 and so on, counting in binary goes 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101. The concept is identical—you just need a lot more digits for binary numbers because there are so many fewer values allowed for each digit. For example, the number “13” in decimal is the same as “1101” in binary. How? Well, in decimal, we have a 3 in the one’s place, plus a “1” in the “tens” place, which has a value of 10. This is 3+10=13. In binary, we have a “1” in the “ones” place, plus a “1” in the “fours” place, plus a “1” in the “eights” place, which is 1+4+8 or 13.

To take a more complex example, 211 in decimal is 11010011 in binary. Table 2 shows how the two are equivalent, by adding the values for each binary digit place where there is a 1. Read it from left to right, going top to bottom. Starting in the left-most column, we see that the example number has a 1 in the "128s" place. So we start with a sum of 128. In the next column there is a 1 in the "64s" place, so we add 64 for a running sum of 192. But in the "32s" place the binary digit value is 0, so we don't add 32 to the sum. We continue down to the "ones" place to get the decimal equivalent of the binary number.


Table 2: Binary and Decimal Number Equivalents

Binary Number

1

1

0

1

0

0

1

1

Power of Two

27

26

25

24

23

22

21

20

Value of Digit Place

128

64

32

16

8

4

2

1

Value For This Number

128

64

0

16

0

0

2

1

Running Sum (from left to right)

128

128+64 = 192

192

192+16 = 208

208

208

208+2 = 210

210+1 = 211


As you can see from this, a binary number with N digits can hold up to 2N values. So, a byte, with eight bits, can hold 28 or 256 different values, which are numbered from 0 to 255. A 16-bit word can hold 216 or 65,536 values.


Previous Topic/Section
Binary Information and Representation: Bits, Bytes, Nibbles, Octets and Characters
Previous Page
Pages in Current Topic/Section
1
23
Next Page
Decimal, Binary, Octal and Hexadecimal Number Conversion
Next Topic/Section

If you find The TCP/IP Guide useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider purchasing a download license of The TCP/IP Guide. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



Home - Table Of Contents - Contact Us

The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005

© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.