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!

Enjoy The TCP/IP Guide? Get the complete PDF!
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
Decimal, Binary, Octal and Hexadecimal Number Conversion
Previous Page
Pages in Current Topic/Section
1
2
Next Page
Boolean Logic and Logical Functions
Next Topic/Section

Binary, Octal and Hexadecimal Arithmetic
(Page 2 of 2)

Binary Arithmetic

Let's start with binary. Adding binary numbers is the same as adding decimal ones, but you end up doing a lot of carrying of ones since there are so few values allowed per digit. Table 7 shows an example, with one digit in each column; read it from right to left and top to bottom, just as you would usually do manual addition. So we start by adding the "1" in the "ones" place from the first number with the "1" in that place from the second number, yielding a raw digit sum of 2. This means the result for the "ones" digit is "1" and we carry a 1 to the "twos" place. We continue with this process until we have added all the digits.


Table 7: Binary Addition

Carry

 

1

1

 

 

1

1

First Binary Number

1

0

1

1

0

0

1

1

Second Binary Number

0

0

1

1

1

0

0

1

Raw Digit Sum

1

1

3

2

1

1

2

2

Result

1

1

1

0

1

1

0

0

Carry to Next Higher Digit

 

 

1

1

 

 

1

1


Octal and Hexadecimal Arithmetic

Octal and hexadecimal are pretty much the same, except that you carry if the sum in a particular digit exceeds either 8 or 16, respectively. Hexadecimal is more common, and more interesting, so let's take an example of adding two hex numbers together. While performing the operation, you will need to do conversions of single-digit hex numbers to decimal and back again, but this isn't too difficult.

This example is shown in Table 8, which again should be read from right to left. We start by adding "8" (decimal 8) to "A" (decimal 10) in the "ones" place. This yields a raw sum of 18, from which we carry 16 as a "1" to the "16s" place and leave a result of 2. We add this 1 to the "D" (value 13) and "E" (14 value) of the "16s" place. This is a total of 28, leaving 12 ("C" in hexadecimal) and we carry a 1 to the "256s" place. This continues until we are left with a sum of 6DC2h.


Table 8: Hexadecimal Addition

Carry

 

1

1

 

First Hex Number

2

C

D

8

Second Hex Number

4

0

E

A

Raw Digit Sum

2+4 = 6

1+12+0 = 13

1+13+14 = 28

8+10 = 18

Result

6

D

C

2

Carry to Next Higher Digit

 

 

1

1


Previous Topic/Section
Decimal, Binary, Octal and Hexadecimal Number Conversion
Previous Page
Pages in Current Topic/Section
1
2
Next Page
Boolean Logic and Logical Functions
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.