![]() |
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 left-digit * 101 + right-digit * 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*103 + 7*102 + 5*101 + 1*100
= 2*1000 + 7*100 + 5*10 + 1
= 2000 + 700 + 50 + 1
= 2751
67048 = 6*104 + 7*103 + 0*102 + 4*101 + 8*100
= 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 Non-Hex 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: True-False; Parent-Child; On-Off; Discount-NoDiscount; Male-Female; Yes-No, 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 Four-Bit 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 non-represented 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 4-bit 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: 27 + 26 + 25 + 24 +
23 + 22 + 21 + 20
= 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 16-bit, 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 4-bits is called the Low Order nibble. The group of the most left 4-bits 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*215+ 1*214 +1*213 + 1*212 + 1*211 + 1*210 + 1*29 + 1*28 + 1*27 + 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 20
= 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 4-bits with an f or F: |
|
||||||||||||||||||||||||||||
|
Counting on base and extending the table we used earlier, we would get: |
|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
| = 65535 | |||||||||||||||||||||||||||||||
|
A Double-Word |
|
A double-word is a group of two consecutive Words. This means a double-word 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 double-word 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*231 + 1*230 + 1*229 + 1*228 + 1*227 + 1*226 + 1*225 + 1*224 + 1*223 + 1*222 + 1*221 + 1*220
+ 1*219 + 1*218 + 1*217 + 1*216 + 1*215 + 1*214 + 1*213 + 1*212 + 1*211 + 1*210 + 1*29 + 1*28 + 1*27
+ 1*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 20
= 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 4-bits 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: |
| 2n-1 | 230 | 229 | 228 | 227 | 226 | 225 | 224 |
| etc | 1,073,741,824 | 536,870,912 | 268,435,456 | 134,217,728 | 67,108,864 | 33,554,432 | 16,777,216 |
| 223 | 222 | 221 | 220 | 219 | 218 | 217 | 216 |
| 8,388,608 | 4,194,304 | 2,097,152 | 1,048,576 | 524,288 | 262,144 | 131,072 | 65,536 |
| 215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 |
| 32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 |
| 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
| 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: |
|
|
|