Hexadecimal numbers can be manipulated in exactly the same was as decimal. The digits we can use are: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Let us take two numbers, say, 7 and 6. In decimal, we can count from 7 upward by 6... 8, 9, 10, 11, 12, 13. In Hexadecimal, we can do the same... 8, 9, A, B, C, D. Let's take two more numbers, D and 4. We count upwards from D by 4... E, F, 10, 11. Notice that after F, there is no other digit we can use, to we carry 1 to the 16's column and carry on counting to reach the final figure of 11Hex. This is just the same as the decimal procedure of carrying to the tens column after we pass 9. Once you have got your head around the idea of extra digits, the rest of it is as easy as decimal.
Pretty much the same way that you add decimal numbers, except that you roll over to the next digit after 7 instead of 9. 1+1 = 2 2+2 = 4 3+3 = 6 4+4 = 10 5+5 = 12 6+6 = 14 7+7 = 16 10+10 = 20 11+11 = 22 Or you can convert to decimal, add, convert back if that's easier. 11o = 1*8^1 + 1*8^0 = 9d 9+9d = 18d 18d = 22o
If you mean using the programming language, it'll do it automagically, for example, if you have in C:
int a = 0x389;
int b = 0x7A8;
int c = a + b;
then c will contain 0xB31 (in hexadecimal) - to display the value you would use:
printf("a + b = %X + %X = %X = c\n", a, b, c);
You can also convert to hexadecimal (for display) directly, for example:
printf("0x%x + 0x%x = 0x%x\n", 127, 207, 127 + 207);
which will display the sum in hex:
0x7f + 0xcf = 0x14e
Hex is only a convenient way to display the numbers to humans.
If you mean manually, yourself, then exactly the same way that you add in any other base.
Start at the right hand end, add the digits together and when it becomes greater than the highest digit that can be stored in a single digit, subtract multiples of the base, write the remaining digit in the answer and the number of multiples of the base subtracted is added as a carry to the next digit sum to the left.
With hexadecimal, just remember that:
0x8 + 1 = 0x9
0x9 + 1 = 0xA
0xA + 1 = 0xB
0xB + 1 = 0xC
0xC + 1 = 0xD
0xD + 1 = 0xE
0xE + 1 = 0xF
0xF + 1 = 0x10
A trick to thinking in hexadecimal is to remember that 8 is 1/2 of 16 and think of the digits above 7 as (8 + [0-7]), that is:
0x8 = (8 + 0), 0x9 = (8 + 1), 0xA = (8 + 2), 0xB = (8 + 3)
0xC = (8 + 4), 0xD = (8 + 5), 0xE = (8 + 6), 0xF = (8 + 7)
and remembering that 0x8 + 0x8 = 0x10.
Example:
0x389 + 0x7A8 = 0xB31
0x9 + 0x8 (= 8 + 1 + 8 = 0x10 + 1) = 0x11 = 0x1 carry 1
0x8 + 0xA + carry 1 (= 8 + 8 + 2 + 1 = 0x10 + 3) = 0x13 = 0x3 carry 1
0x3 + 0x7 + carry 1 (= 8 + 3) = 0xB
If you can't think using the fifteen single digits, work in decimal remembering the conversions:
0xA = 10
0xB = 11
0xC = 12
0xD = 13
0xE = 14
0xF = 15
For example the second addition above becomes:
0x8 + 0xA + carry 1 = 8 + 10 + 1 = 19 (= 16 + 3 = 0x10 + 3) = 0x13 = 0x3 carry 1
Considering the lowest five digit hexadecimal number is 10000 (65,536) and the highest is FFFFF (1,048,575), there are 983,040 different hexadecimal numbers that are five digits.
990 = 3DE
42
hexadecimal decoder
import java.util.Scanner; public class NumberSystem { public void displayConversion() { Scanner input = new Scanner(System.in); System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal", "Binary", "Octal", "Hexadecimal"); for ( int i = 1; i <= 256; i++ ) { String binary = Integer.toBinaryString(i); String octal = Integer.toOctalString(i); String hexadecimal = Integer.toHexString(i); System.out.format("%-20d%-20s%-20s%-20s\n", i, binary, octal, hexadecimal); } } // returns a string representation of the decimal number in binary public String toBinaryString( int dec ) { String binary = " "; while (dec >= 1 ) { int value = dec % 2; binary = value + binary; dec /= 2; } return binary; } //returns a string representation of the number in octal public String toOctalString( int dec ) { String octal = " "; while ( dec >= 1 ) { int value = dec % 8; octal = value + octal; dec /= 8; } return octal; } public String toHexString( int dec ) { String hexadecimal = " "; while ( dec >= 1 ) { int value = dec % 16; switch (value) { case 10: hexadecimal = "A" + hexadecimal; break; case 11: hexadecimal = "B" + hexadecimal; break; case 12: hexadecimal = "C" + hexadecimal; break; case 13: hexadecimal = "D" + hexadecimal; break; case 14: hexadecimal = "E" + hexadecimal; break; case 15: hexadecimal = "F" + hexadecimal; break; default: hexadecimal = value + hexadecimal; break; } dec /= 16; } return hexadecimal; } public static void main( String args[]) { NumberSystem apps = new NumberSystem(); apps.displayConversion(); } }
That depends what you want to "solve" for - in other words, what the question is. For example, whether you want to:* Convert from hexadecimal to decimal* Convert from decimal to hexadecimal* Count in hexadecimal* Add hexadecimal numbers* etc.
To develop a program using the ADI instruction to add the two hexadecimal numbers 3AH and 48H and store the result in memory location 2100H
AAAAAAAAAAAA is the Hexadecimal.
If the above is decimal then in hexadecimal it is 2964492C2. If it is binary then in hexadecimal it is 7DA. If it is octal then in hexadecimal it is 49241208.
234 in hexadecimal is EA.
That depends what you want to "do" with the hexadecimals - add, multiply, compare, etc. The first thing you would need to do is learn how it is defined.
The hexadecimal for 14 is the letter E.
It equates to 26 in hexadecimal.
D63A
60 in hexadecimal would be 3C
19 in hexadecimal is 25 in decimal. 20 follows it and is 26 in hexadecimal.19 in decimal is 13 in hexadecimal. 20 in decimal is 14 in hexadecimal.
4 is 4 in hexadecimal of decimal.