The Numeric Systems 
Introduction 
In computer programming, a variable is an area of computer memory used to (temporarily) hold a value so you can request that value when you judge it necessary and ignore it when not needed. To "reserve" that area of memory, you let your compiler or interpreter know. This is referred to as declaring the variable. To declare a variable, you must give it a name. The name allows you and the compiler or the interpreter to refer to that particular area of the computer memory. After this declaration, an area of memory is reserved for a certain amount of space. How much space is necessary? How does the compiler figure out that space? This detail is taken care of by your supplying another piece of information called a data type. To determine the amount of space necessary, the computer deals with a numeric system. There are three numeric systems that will be involved in your programs, with or without your intervention. The decimal system provides the counting techniques that you use everyday but that the computer is not familiar with. The hexadecimal system is an intermediary system that can allow you to know how the computer deals with numbers. The binary system is the technique the computer uses to find out (almost) everything in your program. 
The Binary System 
The real and only system that the computer recognizes is made of only two symbols 0 and 1. In effect, the computer considers a piece of information to be true or to be false; and it assigns a value accordingly. Therefore, the binary system only counts 0 and 1. To get a number, you combine these values. Examples of binary numbers are 1, 100, 1011, or 1101111011. When reading a binary number such as 1101, you should not pronounce "One Thousand One Hundred And 1", because such a reading is not accurate. Instead, you should pronounce 1 as One and 0 as zero or o. 1101 should be pronounced One One Zero One, or One One o One. The sequence of the symbols of the binary system depends on the number that you are trying to represent. 
The Decimal System 
The numeric system that we have always used uses a set of ten symbols that are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each of these symbols is called a digit. Using a combination of these digits, you can display numeric values of any kind, such as 240, 3826 or 234523. This system of representing numeric values is called the decimal system because it is based on 10 digits. When a number starts with 0, a calculator or a computer ignores the 0. Consequently, 0248 is the same as 248; 030426 is the same as 30426. 
From now on, we will represent a numeric value in the decimal system without ever starting with 0: this will reduce, if not eliminate, any confusion. Decimal Values: 3849, 279, 917293, 39473 Non Decimal Values: 0237, 0276382, k2783, R3273 
The decimal system is said to use a base 10. This allows you to recognize and be able to read any number. Indeed, the system works in increments of 0, 10, 100, 1000, 10000, and up. In the decimal system, 0 is 0*100 (= 0*1, which is 0); 1 is 1*100 (=1*1, which is 1); 2 is 2*100 (=2*1, which is 2), and 9 is 9*100 (= 9*1, which is 9). Between 10 and 99, a number is represented by leftdigit * 101 + rightdigit * 101. For example, 32 = 3*101 + 2*100 = 3*10 + 2*1 = 30 + 2 = 32. In the same way, 85 = 8*101 + 5*100 = 8*10 + 5*1 = 80 + 5 = 85. Using the same logic, you can get any number in the decimal system. Examples are: 
2751 = 2*10^{3} + 7*10^{2} + 5*10^{1} + 1*10^{0}
= 2*1000 + 7*100 + 5*10 + 1
= 2000 + 700 + 50 + 1
= 2751
67048 = 6*10^{4} + 7*10^{3} + 0*10^{2} + 4*10^{1} + 8*10^{0}
= 6*10000 + 7*1000 + 0*100 + 4*10 + 8*1
= 67048
Another way you can represent this is by using the following table:

When these numbers get large, they become difficult to read; an example is 279174394327. To make this easier to read, we will separate each thousand fraction with a comma. Our number would become 279,174,394,327. We will do this only on paper, never in a program: the compiler would not understand the comma(s). 
The Hexadecimal System 
The decimal system just provides one way of representing numbers. Another technique uses sixteen (16) values to represent a number: this is the hexadecimal system. Since the decimal system provides only 10 digits, we cannot make up new ones. To compensate for this, the hexadecimal system uses alphabetical characters. After counting from 0 to 9, the system adds letters until it gets 16 different values. The letters used are a, b, c, d, e, and f, or their uppercase equivalents A, B, C, D, E, and F. Therefore, the hexadecimal system counts as follows: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f; or 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Once again, to produce a number, you use a combination of these sixteen symbols. Examples of hexadecimal numbers are 293, 0, df, a37, c23b34, or ffed54. At first glance, the decimal representation of 8024 and the hexadecimal representation of 8024 are the same. Also, when you see fed, is it a name of a federal agency or a hexadecimal number? Does CAB represent a taxi, a social organization, or a hexadecimal number? 
Therefore, from now on, to express the difference between a decimal number and a hexadecimal one, each hexadecimal number will start with 0x or 0X. The number will be followed by a valid hexadecimal combination. The letter can be in uppercase or lowercase. Legal Hexadecimals: 0x273, 0xfeaa, 0Xfe3, 0x35FD, 0x32F4e NonHex Numbers: 0686, ffekj, 87fe6y, 312 
Signed and Unsigned Numbers 
You may have noticed that the numbers we have used so far were counting from 0, then 1, then 2, and up to any number desired, in incrementing values. Such a number that increments from 0, 1, 2, and up is qualified as positive. By convention, you do not need to let the computer or someone else know that such a number is positive: by just displaying or saying it, the number is considered positive. In real life, there are numbers counted in decrement values. Such numbers start at 1 and move down to 2, 3, 4 etc. These numbers are qualified as negative. 

When you write a number "normally", the number is positive. If you want to express the number as negative, you use the  on the left side of the number. The  symbol is called a sign. Therefore, if the number does not have the  symbol, C++ (or the compiler) considers such a number as unsigned. In C++, if you declare a variable that would represent a numeric value and you do not initialize (assign a value to) such a variable, the compiler will consider that the variable can hold either a signed or an unsigned value. If you want to let the compiler know that the variable should hold only a positive value, you will declare such a variable as unsigned. 
Numeric Representation 
A Bit 
The computer (or an Intel computer, or a computer that runs on an Intel microprocessor) uses the binary to represent its information. A piece of information in the computer is called a datum; and the plural is data. Sometimes, the word data is used for both singular and plural. The computer represents data using only a 0 or 1 values. To make an illustration, let's consider that a computer uses a small box to represent such a value. This small box can have only one of two states. When the box is empty, we will give it a value of 0. When the box is full, we give it a value of 1. The box can have only one of these two values.
Since this box can have only one of two states, consider that you can use it to represent anything that could assume one out of two values. Examples include: TrueFalse; ParentChild; OnOff; DiscountNoDiscount; MaleFemale; YesNo, etc. This technique of representing values is called The Binary
system. In the computer, it uses values 0 and/or 1, which themselves are called
digits. Therefore, the entity used to represent such a value is called a binary
digit; in its abbreviated form, it is called a bit. The bit (binary digit) is
the most fundamental representation of the computer's counting system. Although
this is valid for the computer, the Intel microprocessors cannot validate a
variable at this level; but eventually, you will be able to manipulate data at
the bit level. 
The FourBit Combination 
The binary system provides the combination of 4 bits as the second value representation of the
system: To count the bits, we number them starting at 0, followed by 1, 2, and 3.
The count starts with the most right bit. The first bit, on the right side of the nibble, is called the Low Order bit or LO bit. The last bit, on the left side of the nibble, is called the High Order bit or HI bit. The other bits are called by their positions: bit 1 and bit 2. This produces the following binary combinations: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111 = 16 combinations. When using the decimal system, these combinations can be resented as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, and 15. As you can see, a nibble is represented by a group of 4 bits. This is also a system that the computer uses to count bits internally. Sometimes, in your program in the help files, you will encounter a number less than four bits, such as 10 or 01 or 101. How do you reconcile such a number to a nibble? The technique used to complete and fill out the nibble consists of displaying 0 for each nonrepresented bit; this makes it easier to recognize. The binary number 10 will be the same as 0010. The number 01 is the same as 0001. The number 101 is the same as 0101. This technique is valuable and allows you to always identify a binary number as a divisor of 4. When all bits in a nibble are 0, you have the lowest value you can get, which is 0000. Any of the other combinations has at least one 0 bit, except for the last one. When all bits are 1, this provides the highest value possible for a nibble. The lowest value, also considered the minimum value, can be represented in the decimal system as 0. The highest value, also considered the maximum, can be expressed in decimal value as 24 (2 represents the fact that there are two possible states: 0 and 1; 4 represents the fact that there are four possible combinations), which is 16. As you can see, the binary system is very difficult to read when a value combines various bit representations. To make your life a little easier, the computer recognizes the hexadecimal representation of bits. Following the box combinations above, we can represent each 4bit of the sixteen combinations using the decimal, hexadecimal, and binary systems as follows: 
Table of numeric conversions 
When looking at a binary value represented by 4 bits, you can get its decimal or hexadecimal values by referring to the table above. For this reason, you may have to memorize it. A nibble, which is a group of four consecutive bits, has a minimum and maximum values on each system: 



A byte combines 8 consecutive bits. Once again, the bits are counted from left to right starting at 0. The most right bit is called the Low Order bit or LO bit. The most left bit is called the High Order bit or HI bit. The other bits are refereed to following their positions. A byte is considered as being made of two nibbles. The right nibble, made of the right 4 bits, is called the Low Order nibble or LO nibble. The left nibble, made of the left 4 bits, is called the High Order nibble or HI nibble. Using the binary system, you can represent the byte using a combination of 0s and 1s. When all bits have a value of 0, the byte is represented as 00000000. On the other hand, when all bits have a value of 1, the byte is represented as 11111111. When the number grows very large, it becomes difficult to read. Therefore, we will represent bits in groups of four. Instead of writing 00000000, we will write 0000 0000. This makes the number easier to read. 
If you get the patience to create combinations of bits using the boxes as we did for the nibble, you would find out that there are 256 possible combinations. Another way to find it out is by using the base 2 technique: 2^{7} + 2^{6} + 2^{5} + 2^{4} + 2^{3} + 2^{2} + 2^{1} + 2^{0 } = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 256^{ } Therefore, the maximum decimal value you can store in a byte is 256. 
When a byte is completely represented with 0s, it
provides the minimum value it can hold; this is 0000 0000, which is also
0. When all bits have a value of 1, which is 1111 1111, a byte holds its
maximum value that we calculated as 255. As done with the nibble, we get
the following table: 

A Word 
A word is a group of 16 consecutive bits. Again, the bits are counted from left to right starting at 0: 
Considered as a group of 16bit, the most right bit of a word is called the Low Order bit or LO bit. The most left bit is called the High Order bit or HI bit. The other bits are referred to using their positions.: bit 1, bit 2, bit 10, etc. When considered as a group of four nibbles, the group of the most right 4bits is called the Low Order nibble. The group of the most left 4bits is called the High Order nibble. The other nibbles are referred to using their positions: nibble
1 and nibble 2. 
The most fundamental representation of a word in binary format is 0000000000000000. To make it easier to read, you can group bits in 4, like this 0000 0000 0000 0000. Therefore, the minimum binary value represented by a word is 0000 0000 0000 0000. The maximum binary value represented by a word is 1111 1111 1111 1111. The minimum decimal value of a word is 0. To find out the maximum decimal value of a word, you can use the base 2 formula, filling out each bit (with 1): 
1*2^{15}+ 1*2^{14 }+1*2^{13} + 1*2^{12} + 1*2^{11} + 1*2^{10} + 1*2^{9} + 1*2^{8} + 1*2^{7} + 1*2^{6} + 1*2^{5} + 1*2^{4} + 1*2^{3} + 1*2^{2} + 1*2^{1} + 2^{0}
= 32768 + 16384 + 8192 + 4096 + 2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 65535
The minimum hexadecimal value you can store in a word is 0x0000000000000000. This is also represented as 0x00000000, or 0x0000, or 0x0. All these numbers produce the same value. To find out the maximum hexadecimal number you can represent with a word, replace every group of 4bits with an f or F: 

Counting on base and extending the table we used earlier, we would get: 






= 65535  
A DoubleWord 
A doubleword is a group of two consecutive Words. This means a doubleword combines 4 bytes, 8 nibbles or 32 bits. The bits, counted from left to right start at 0 and end at 31. 
The most right bit, bit 0, is called the Low Order bit, or LO bit. The most left bit, bit 31, is called the High Order bit, or HI bit. The other bits are called using their positions. The group of the 4 right bits is called the Low Order nibble, or LO nibble. The group of the 4 left bits is called the High Order nibble, or HI nibble. You use their positions when referring to the other nibbles. The group of the first 8 bits (from bit 0 to bit 7), which is the right byte, is called the Low Order Byte, or LO Byte. The group of the last 8 bits (from bit 24 to bit 31), which is the left byte, is called the High Order Byte, or HI Byte. The other bytes are called by their positions. The group of the right 16 bits, or the right Word, is called the Low Order Word, or LO Word. The group of the left 16 bits, or the left Word, is called the High Order Word, or HI Word. 
The minimum decimal value of a doubleword is 0. To find out the maximum decimal value of a word, you can use the base 2 formula giving a 1 value to each bit: 
1*2^{31} + 1*2^{30} + 1*2^{29} + 1*2^{28} + 1*2^{27} + 1*2^{26} + 1*2^{25} + 1*2^{24} + 1*2^{23} + 1*2^{22} + 1*2^{21} + 1*2^{20}
+ 1*2^{19} + 1*2^{18} + 1*2^{17} + 1*2^{16} + 1*2^{15} + 1*2^{14} + 1*2^{13} + 1*2^{12} + 1*2^{11} + 1*2^{10} + 1*2^{9} + 1*2^{8} + 1*2^{7}
+ 1*2^{6} + 1*2^{5} + 1*2^{4} + 1*2^{3} + 1*2^{2} + 1*2^{1} + 2^{0}
= 2,147,483,648 + 1,073,741,824 + 536,870,912 + 268,435,456 + 134,217,728 + 67,108,864 + 33,554,432
+ 16,777,216 + 8,388,608 + 4,194,304 + 2,097,152 + 1,048,576 + 524,288 + 262,144 + 131,072 + 65,536
+ 32,768 + 16,384 + 8,192 + 4,096 + 2,048 + 1,024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 4,294,967,295
The minimum hexadecimal value you can store in a word is 0x0. To find out the maximum hexadecimal number you can represent with a word, replace every group of 4bits with an f or F: 

Conversion from Decimal to Binary 
Converting a Byte From Decimal to Binary 
Remember that the maximum decimal number you can store in a byte is 255. Once you have a decimal number, you can use the remainder operation to fill out the bits. Let's convert the number 206. Considering 206, find out the range of the number. Since this is greater than 128, fill out bit 7 with 1. This produces: 

Next, find the remainder of 206 by 128. This is 206 / 128 = Remainder(78). In C++, this operation would be 206 % 128 = 78. The result, 78, is greater than 64. therefore, fill out the corresponding bit of 64, which is bit 6, with 1: 

Next, find the remainder of 78 by 64. 78 / 64 = Remainder(14). This is equivalent in C++ to 78 % 64 = 14. 14 is less than 32. Therefore, the bit corresponding to decimal 32, which is bit 5, has a binary value of 0. 14 is less than 16. Therefore, bit 4 is 0. 14 is greater than 8. Therefore, fill out bit 3 with 1: 

Now, find the remainder of 14 by 8. 14 % 8 = 6. 6 is greater than 4. Therefore, bit 2 has a binary value of 1. 

Find the remainder of 6 by 4: 6 % 4 = 2. According to this, bit 1 will have a binary value of 1. The remaining decimal value is 0. Therefore, bit 0 has a value of 0. The decimal number 206 produces the following table: 

Converting any Number From Decimal to Binary 
Converting a decimal number to binary takes longer because of the various comparisons you would perform. There are, as always, various techniques available. Once again, find the range of the number using numbers such as those: 
2^{n1}  2^{30}  2^{29}  2^{28}  2^{27}  2^{26}  2^{25}  2^{24} 
etc  1,073,741,824  536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216 
2^{23}  2^{22}  2^{21}  2^{20}  2^{19}  2^{18}  2^{17}  2^{16} 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
2^{15}  2^{14}  2^{13}  2^{12}  2^{11}  2^{10}  2^{9}  2^{8} 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
2^{7}  2^{6}  2^{5}  2^{4}  2^{3}  2^{2}  2^{1}  2^{0} 
128  64  32  16  8  4  2  1 
Imagine you would like to convert the following decimal number 408340623 = 408,340,623 to binary.
(I picked this number completely randomly) 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1 
At this time, we have the number as 1 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1 
The current number is 11000 or 1 1000 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0 
Since 4,194,304 is immediately less than 5,687,439 fill it with 1
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1 
The number becomes 1100001 or 110 0001 Then find the remainder of 5,687,439 by 4,194,304. This produces 1,493,135. This number is greater than 1,048,576. Therefore, write 0 under 2,097,152 and 1 under 1,048,576. 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1 
Now the number is 110000101 or 1 1000 0101 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1 
The number has become 11000010101 or 110 0001 0101 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1 
The current number is 110000101011 or 1100 0010 1011 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1 
The current number is 11000010101101 or 11 0000 1010 1101 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1 
The number becomes 110000101011011 or 110 0001 0101 1011 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1 
The number becomes 110000101011011001 or 11 0000 1010 1101 1001 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1  0  0  0 
128  64  32  16  8  4  2  1 
1 
The current number is 1100001010110110010001 or 11 0000 1010 1101 1001 0001 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1  0  0  0 
128  64  32  16  8  4  2  1 
1  0  0  0  1 
The current number is: 11000010101101100100010001 or 11 0000 1010 1101 1001 0001 0001 The remainder of 15 by 8 is 7, which is greater than 4. Fill out bit 2 with 1. 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1  0  0  0 
128  64  32  16  8  4  2  1 
1  0  0  0  1  1 
The current number is: 110000101011011001000100011 or 110 0001 0101 1011 0010 0010 0011 The remainder of 7 by 4 is 3, which is greater than 2. This produces: 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1  0  0  0 
128  64  32  16  8  4  2  1 
1  0  0  0  1  1  1 
The current number is: 
536,870,912  268,435,456  134,217,728  67,108,864  33,554,432  16,777,216  
0  1  1  0  0  0 
8,388,608  4,194,304  2,097,152  1,048,576  524,288  262,144  131,072  65,536 
0  1  0  1  0  1  1  0 
32,768  16,384  8,192  4,096  2,048  1,024  512  256 
1  1  0  0  1  0  0  0 
128  64  32  16  8  4  2  1 
1  0  0  0  1  1  1  1 
The final number is: The equivalent decimal number of 408340623 in binary is 11000010101101100100010001111 or 1 1000 0101 0110 1100 1000 1000 1111 This number can easily be converted from binary to hexadecimal using the table of numeric conversions: 
0001  1000  0101  0110  1100  1000  1000  1111 
1  8  5  6  C  8  8  F 
= 0x1856C88F 
Conversion from Binary to Decimal 
Converting a Byte From Binary To Decimal 
Since the bits are numbered from right to left , you can calculate the decimal value of a byte using the base 2. Consider a binary number intensely mixed with 0s and 1s such as 11010111. The 11010111 can be calculated as: 






= 215  
An alternative to calculating such a number is by using the following table: 
Decimal to Binary Conversion Table 
When you are presented with a binary number, you can just write the corresponding bit value under the ranking decimal number. Consider that you want to calculate the decimal equivalent of the 01110110 binary number. Using the last table, you can perform the operation like this: 

This produces: 
= 64 + 32 + 16 + 4 + 2 = 118 
Using any of these techniques, you can find out the value of a combination of any 8 consecutive bits. When all bits are 0, the byte also has a value of 0. When combining and mixing 0 and 1 bits, you can get binary values as varied as possible: 0101 0010 or 1101 1110 or 0111 1100. We only need to know what each combination would represent.
Considerer another binary number such as 11001000. To convert it to the
decimal system, we use the decimal to binary table conversion to get: 
= 128 + 64 + 0 + 0 + 8 + 0 + 0 + 0 = 128 + 64 + 8 = 200 
Converting any Number From Binary To Decimal 
Once you are presented with a binary number, you can produce or use a table inspired from the binary to decimal conversion table: 
Etc  2^{14}  2^{13}  2^{12}  2^{11}  2^{10}  2^{9}  2^{8}  2^{7}  2^{6}  2^{5}  2^{4}  2^{3}  2^{2}  2^{1}  2^{0} 
Etc  16384  8192  4096  2048  1024  512  256  128  64  32  16  8  4  2  1 
Imagine you would like to convert the 10011110011101101 binary number to a decimal value.
1  0  0  1  1  1  1  0  0  1  1  1  0  1  1  0  1 
65536  32768  16384  8192  4096  2048  1024  512  256  128  64  32  16  8  4  2  1 
= 65536 + 0 + 0 +8192+4096+2048+1024+ 0 + 0 + 128+ 64 +32 + 0 + 8 + 4 + 0 + 1
= 65536 +
8192+4096+2048+1024 +
128+ 64 +32 + 8
+ 4 + 1
= 81133
Conversion from Decimal to Hexadecimal 
Converting a Byte From Decimal to Hexadecimal 
To convert a decimal value of a byte to its hexadecimal equivalent, again keep in mind that the maximum number you are dealing with is 255 (this is because the operation will be a little different later on). Find the remainder of the decimal number by 16. This remainder will constitute the low nibble. The result will constitute the high nibble. Therefore, use the table of numeric conversions to find the equivalent hexadecimal number for each nibble. Let's convert decimal 225 to hexadecimal. The remainder of 225 by 16 is 225 % 16 = 1 and the natural result is 14. Using the table of numeric conversions, decimal 14 = hexadecimal E. Decimal 1 = hexadecimal 1. Therefore, the decimal number 225 has a hexadecimal value of 0XE1. As another example, Let's convert the decimal 203 to the hexadecimal system. 203 % 16 = 11 and the natural result is 12. Using the table of numeric conversions, decimal 12 = hexadecimal C; decimal 11 = hexadecimal B. Therefore, decimal 203 = hexadecimal 0XCB 
Converting any Number From Decimal to Hexadecimal 
To convert any number from decimal to hexadecimal, find the remainder of the number by 16. This remainder would be the LO nibble. Use the quotient to find the remainder by 16; this remainder would be the second nibble. Continue until the decimal is less than 16. Consider a decimal number such as 1325 to convert to hexadecimal. The remainder of 1325 by 16 is 1325 % 16 = 13 and the quotient is 82. Therefore the left number will be 13. 82 % 16 = 2 and the quotient is 5. Therefore, the second number from left is 2; this would produce 2 and 13. Since the quotient, 5, is less that 16, it will be put to the left of the existing numbers. We get 5  2  13. According to the table of numeric conversions, decimal 13 = hexadecimal D. Therefore, decimal 1325 = hexadecimal 0x52D Let’s convert decimal 462834 to hexadecimal:

Conversion from Hexadecimal to Decimal 
Converting a Byte From Hexadecimal to Decimal 
A byte is made of 8 bits. This means that the highest hexadecimal value you can represent with a byte is 0xFF and the highest decimal value is 255. To convert a hexadecimal number to decimal, multiply each hexadecimal digit to its 16 base value. Starting on the left side, which is the low order bit, use the following table:
Consider a hexadecimal byte represented with 0x24, to convert it to decimal, you would use: = (2 * 16) + (4 * 1) = 32 + 4 = 36 Therefore, the decimal equivalent of 0x24 is 36 Consider another hexadecimal number as 0x5D. To convert it to decimal, you would write: 5 * 16^{1} + D * 16^{0}. If you look at the table of numeric conversions, 
Table of numeric conversions 
you would see that the decimal value of hexadecimal D is 13. Therefore, the conversion would be performed as follows: = 5 * 16^{1} + 13 * 16^{0} = (5 * 16) + (13 * 1) = 80 + 13 = 93 Therefore, hexadecimal 0x5D = decimal 93 
Converting any Number From Hexadecimal to Decimal 
To convert a hexadecimal number to decimal, multiply each digit of the hexadecimal number to its 16base equivalent. Starting from the = (8 * 65536) + (0 * 4096) + (3 * 256) + (2 * 16) + (9 * 1) = 524288 + 0 + 768 + 32 + 9 = 525097 = (11 * 1048576 ) + (14 * 65536) + (4 * 4096) + (5 * 256) + (10 * 16) + (6 * 1) = 11534336 + 917504 + 16384 + 1280 + 160 + 6 = 12469670 = 12,469,670 
Conversion from Binary to Hexadecimal 
Converting a Byte From Binary to Hexadecimal 
When all bits are 0, the byte also has a value of 0. When combining and mixing 0 and 1 bits, you can get binary values as varied as possible: 0101 0010 or 1101 1110 or 0111 1100. We only need to know what each combination would represent. If you divide bits by groups of four, you can use the table of numeric conversions to find out what each group represents. Consider a binary number such as 10101101. Dividing it in groups of 4bits, we get 1010 1101. Referring to our conversion table, the low order nibble has a hexadecimal value of 8. The high order nibble has a hexadecimal value of C.


Therefore, the binary number 10101101 has a hexadecimal representation of 0XAD. Of course, the binary number 10101101 is equivalent to 128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173 in the decimal system 
Converting any Number From Binary to Hexadecimal 
To convert a binary number to hexadecimal, use the table of numeric conversions. First, convert the number in groups of 4 bits. If the most left group has less than 4 bits, complete the other bits with 0 each. 11 0001 1111 1110 1101 1100 Since the most left group has only 2 bits, you can add two 0 bits to its left to make it a group of 4. The number becomes: 0011 0001 1111 1110 1101 1100 Using the table of numeric conversions, you get: 0011 0001 1111 1110 1101 1100 
Conversion from Hexadecimal to Binary 
Converting a Byte From Hexadecimal to Binary 
The conversion of a hexadecimal number to its binary equivalent is extremely easy. The only thing you need is the table of numeric conversions. A byte is represented with two hexadecimal symbols. The right symbol represents the low nibble (the first 4 bits). The other symbol is the high nibble. Consider a hexadecimal number such as 0X26. Referring to our table of numeric conversions, 2 has a binary representation of 0010; hexadecimal 6 is represented in binary as 0110. Therefore, the hexadecimal number 0X26 can be represented in binary as 00100110 which is easily read as 0010 0110. Remember that when a number has leading 0s, the computer ignores the 0(s). As a result, the computer would display 00100110 as 100110 Let's convert the hexadecimal 0XD5 to binary. The binary representation of D is 1101. The binary representation of 5 is 0101. Therefore, hexadecimal 0XD5 is represented in binary as 11010101 or 1101 0101 
Converting any Number From Hexadecimal to Binary 
To convert any hexadecimal number to binary, once again, you use the table of numeric conversion. Each hexadecimal digit will be converted to its binary equivalent. Consider you would like to convert the hexadecimal number 0x72FA to binary. Using the table of numeric conversions: 7 = 0111 Therefore, hexadecimal 0x72FA is represented in binary as 011100101111010. This can be read as 0111 0010 1111 1010. The computer would display it as 11100101111010 

Copyright © 20032012 FunctionX 
