 

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.
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 singledigit 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.
Home  Table Of Contents  Contact Us The TCP/IP Guide (http://www.TCPIPGuide.com) Version 3.0  Version Date: September 20, 2005 © Copyright 20012005 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. 