How do computers convert binary to decimal?

Bits represent one of two values, 0 or 1, and are joined together to form binary numbers. Each column of a binary number has twice the weight of the previous column, so binary numbers are base 2. In binary, the column weights (again, from right to left) are 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, and so on. If you work with binary numbers often, you’ll save time if you remember these powers of two up to 216.

An N-bit binary number represents one of 2N possibilities: 0, 1, 2, 3, …, 2N − 1. Table 1.1 shows 1-, 2-, 3-, and 4-bit binary numbers and their decimal equivalents.

Table 1.1. Binary numbers and their decimal equivalent

1-Bit Binary Numbers2-Bit Binary Numbers3-Bit Binary Numbers4-Bit Binary NumbersDecimal Equivalents000000000001010010001110010001021101100113100010041010101511001106111011171000810019101010101111110012110113111014111115

Example 1.1

Binary To Decimal Conversion

Convert the binary number 101102 to decimal.

Solution

Figure 1.5 shows the conversion.

How do computers convert binary to decimal?

Figure 1.5. Conversion of a binary number to decimal

Example 1.2

Decimal To Binary Conversion

Convert the decimal number 8410 to binary.

Solution

Determine whether each column of the binary result has a 1 or a 0. We can do this starting at either the left or the right column.

Working from the left, start with the largest power of 2 less than or equal to the number (in this case, 64). 84 ≥ 64, so there is a 1 in the 64’s column, leaving 84 − 64 = 20. 20 < 32, so there is a 0 in the 32’s column. 20 ≥ 16, so there is a 1 in the 16’s column, leaving 20 − 16 = 4. 4 < 8, so there is a 0 in the 8’s column. 4 ≥ 4, so there is a 1 in the 4’s column, leaving 4 − 4 = 0. Thus, there must be 0 s in the 2’s and 1’s column. Putting this all together, 8410 = 10101002.

Working from the right, repeatedly divide the number by 2. The remainder goes in each column. 84/2 = 42, so 0 goes in the 1’s column. 42/2 = 21, so 0 goes in the 2’s column. 21/2 = 10 with the remainder of 1 going in the 4’s column. 10/2 = 5, so 0 goes in the 8’s column. 5/2 = 2 with the remainder of 1 going in the 16’s column. 2/2 = 1, so 0 goes in the 32’s column. Finally, 1/2 = 0 with the remainder of 1 going in the 64’s column. Again, 8410 = 10101002.

Read moreNavigate Down

View chapterPurchase book

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780128200643000015

Introduction to Sniffer Pro

Robert J. Shimonski, ... Yuri Gordienko, in Sniffer Pro Network Optimization and Troubleshooting Handbook, 2002

Binary to Hex to Decimal Translation

We generally use the base10 (also known as decimal) numbering system, which uses 10 values (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to represent numbers.

Computers use the base2 (also known as binary) numbering system to represent data. The binary numbering system uses two values, 0 and 1, to represent numbers. This is because a computer only recognizes two states: the presence or absence of an electrical charge. Even if a computer is showing you decimal numbers, it is merely a translation of the binary numbers inside the machine. A single binary digit (0 or 1) is called a bit. The term octet is used to describe a unit of 8 bits. Most modern computers also have 8 bits in a byte. In the early days of computers, the word byte was also used to describe other quantities of bits. The term nibble is equal to half a byte and is therefore 4 bits, in most cases.

Hexadecimal is base16 and therefore uses 16 values (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) to represent numbers. The hexadecimal system is useful because a byte (8 bits) of binary data can be represented using just two hexadecimal digits. This makes it easier for humans to read or write large numbers in hexadecimal rather than binary format.

We will first learn how to convert a decimal number into binary. A popular method for converting a decimal number into binary is to divide the number by 2 repeatedly. Let's take the decimal number 35 as an example. Figure 1.6 shows how this decimal number can be converted into binary format. Here are the steps:

How do computers convert binary to decimal?

Figure 1.6. Conversion of the Decimal Number 35 into Binary Format

1.

Divide the original number by 2. The remainder becomes the least significant bit in the binary number.

2.

Divide the result of the division from Step 1 by 2. The remainder becomes the next most significant bit of the binary number.

3.

Repeat the division process until the result is 0. The remainders form the binary number.

Let's now look at binary-to-decimal conversion. Here we simply multiply the binary digits by increasing powers of 2, starting from the right. Let's walk through the steps involved in converting the binary number 101 into decimal format:

1.

The rightmost digit is a 1, so you multiply it by 2 to the 0th power (or 1): 1 × 1 = 1.

2.

Multiply the next digit to the left (0) by 2 to the first power (or 2): 0 × 2 = 0.

3.

Multiply the next digit to the left (1) by 2 to the second power (or 4): 1 × 4 = 4.

4.

Now, to find the decimal number, you find the sum of these products: 1 + 0 + 4 = 5. Therefore, 101 in binary equals 5 in base 10.

Hexadecimal-to-binary conversion is easily accomplished by converting each hexadecimal digit to decimal first and then converting each of these decimal values into binary. As an example, take the hexadecimal number 05DC:

1.

Convert each digit to decimal, one by one. This results in the decimal values 0, 5, 13, and 12.

2.

Convert each of these decimal numbers into 4 bits of binary. This gives us the binary values 0000, 0101, 1101, and 1100.

3.

Put these binary values next to each other. We get 0000010111011100.

To convert binary to hexadecimal, reverse this method. Group the binary number into 4-bit nibbles, and convert each group into decimal. Finally, replace each decimal number with its hex equivalent. As an example, take the binary value 1101101101010110:

1.

When we divide the value into 4-bit nibbles, we get 1101, 1011, 0101, and 0110 (the first line in Figure 1.7).

How do computers convert binary to decimal?

Figure 1.7. Converting the Binary Number 1101101101010110 into Hex Format

2.

Convert each nibble into its decimal equivalent. This results in 13, 11, 5, and 6 (the second line in Figure 1.7).

3.

Replace each decimal number with its hex equivalent. This results in the final value of DB56 (the third line in Figure 1.7).

NOTE

You will find that knowing how to perform base conversion is essential to a network analyst's job. Computer data, including networking protocols, is often represented in binary or hexadecimal format.

Read moreNavigate Down

View chapterPurchase book

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9781931836579500058

Karnaugh maps and function simplification

B. HOLDSWORTH BSc (Eng), MSc, FIEE, R.C. WOODS MA, DPhil, in Digital Logic Design (Fourth Edition), 2002

3.5 The Karnaugh map

For two variables there are four minterms and these can be conveniently placed on a ‘map’ as shown in Figure 3.4. The map consists of a square divided into four cells, one for each of the minterms. The possible values of the variable A are written down the left hand side of the map, labelling the corresponding rows of the map, while the possible values of the variable B are written along the top of the map, labelling the corresponding columns of the map. Hence, the top left-hand cell represents the minterm where A = 0 and B = 0, i.e. the minterm A¯B¯The bottom right-hand cell represents the minterm AB where A = 1 and B = 1. This kind of map is called a Karnaugh map or K-map.

How do computers convert binary to decimal?

Figure 3.4. The map for two Boolean variables

Karnaugh maps can be labelled and marked in a variety of ways. For example, each cell can be numbered with the decimal subscript of the minterm that occupies the cell. In this case, the bottom right-hand cell would be numbered with 3, as shown in Figure 3.5(a). The cell numbering shown in Figure 3.5(a) assumes that A is the most significant bit in the binary to decimal conversion, and B the least significant bit. Since A has weighting 2 and B has weighting 1, this is sometimes indicated in abbreviated form as A, B ≡ 2,1 (which is not a conventional equation, but merely indicates the respective weights of A and B). Alternatively, the cells can be marked with the binary representation of their corresponding subscript, as shown in Figure 3.5(b). A further possibility for the axis labels is to use A, A¯, B, B¯instead of 0 and 1, as shown in Figure 3.5(c).

How do computers convert binary to decimal?

Figure 3.5. Alternative methods for marking a Karnaugh map

For three variables, the map contains eight cells, one for each of the possible minterms as shown in Figure 3.6(a), drawn for the weighting A, B, C ≡ 4,2,1. The variable A is allocated to the two rows of the map, while the variables B and C are allocated to the four columns. There are four combinations of these two variables, and each combination is allocated to a column of the map.

How do computers convert binary to decimal?

Figure 3.6. Karnaugh maps for three variables

The columns and rows are allocated in the way shown so that two adjacent columns are always associated with the true value of a variable or, alternatively, its complement. An examination of Figure 3.6(a) shows that the first two columns are associated with the second and third columns are associated with C, and the third and fourth columns are associated with B. The reason for allocating the variables to the columns in this way will be clearer when the procedure for minimisation of a Boolean function is discussed later in this chapter. Note, however, that the column labels along the top of the K-map are the same as the Gray code order for two binary variables (see section 1.21). The reason for this is that the underlying principle of the K-map is that in moving from one cell to an adjacent cell either vertically or horizontally, the value of one (and only one) Boolean variable may change, and of course similarly Gray codes must change by just one digit only at each step. An alternative method of labelling the axes of a 3-variable K-map is shown in Figure 3.6(b), which makes clear that two adjacent columns are always associated with either the true value or the complement of a variable.

The 4-variable K-map is shown in two forms, differing only in the axis labelling method, in Figure 3.7. Since there are 16 minterms for four variables, the map contains 16 cells and each cell has been marked with the decimal subscript of its respective minterm, using the weighting A, B, C, D ≡ 8, 4, 2, 1. Note that in Figure 3.7(a), both axes are labelled in Gray code order.

How do computers convert binary to decimal?

Figure 3.7. Karnaugh maps for four variables

In the case of five variables, it is convenient to use two 16-cell maps rather than one 32-cell map, as shown in Figure 3.8(a). The right-hand map is allocated to the true value of E, while the left-hand map is associated with the complement of variable E.

How do computers convert binary to decimal?

Figure 3.8. Karnaugh maps for five variables, using the weighting A, B, C, D, E ≡ 16, 8, 4, 2, 1

An alternative is to start with a single 4-variable K-map, and to subdivide each original square cell diagonally, as shown in Figure 3.8(b) to produce a single 32-cell map, so that the cells now become triangles; E is associated with the upper-left triangles, and with the lower-right triangles.

For six variables, there are 64 minterms, and so 64 cells are required; the possibilities are to use four 16-cell maps, or two 32-cell maps, or a single 64-cell map produced by taking a 32-cell map and subdividing each original square cell diagonally again to produce four triangular cells in the space of each original square cell, as shown in Figure 3.9. In each case, all possible combinations of E and F are accommodated uniquely.

How do computers convert binary to decimal?

Figure 3.9. Karnaugh maps for six variables, using the weighting A, B, C, D, E, F ≡ 32, 16, 8, 4, 2, 1

Read moreNavigate Down

View chapterPurchase book

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780750645829500044

Mobile Extraction Issues

Brett Shavers, John Bair, in Hiding Behind the Keyboard, 2016

Encoding

Now that we have addressed the location of where user data may reside, what issues can be expected when we actually locate the data? Unlike computer forensics which generally has specific ways in which encoding can be interpreted, mobile device encoding can vary. This also includes date and times which we address later in this chapter.

The data that is recovered through a physical acquisition will at times need to be decoded. As previously addressed, data may reside in hardware physical memory, or software locations such as the previously mentioned SQLite databases. Here are the common types of encoding that will be found.

Binary

Hexadecimal

Nibble

American Standard Code for Information Exchange (ASCII)

Unicode

7-bit GSM protocol description unit (PDU)

Binary

The lowest level of encoding is binary. Mobile devices like computers will contain bits that are either a “1” or a “0.” This represents if the bit is on or off. 1 means the bit is on while 0 is off. A total of 8 bits equals 1 byte.

Binary to Decimal

The binary value can be converted to decimal, the total of 8 bits in a byte can hold a value if it is on or off. If all of the bits were on (in the 1 position) the total value would be 255. Fig. 4.8 is an example of the binary to decimal conversion in a byte.

How do computers convert binary to decimal?

Figure 4.8. (1) Byte Binary to Decimal conversion example.

Binary numbers can represent letters and characters. Standard ASCII charts can provide the decoded values without the need to manually covert them. It is important to understand that binary is one of the core encoding types, and knowing how to convert manually can help with validation.

Hexadecimal

Four (4) binary digits represent hexadecimal. These four binary digits are known as a “nibble.” Two nibbles equal a byte. This equates to eight binary digits. Fig. 4.9 shows two nibbles representing one-byte value. Binary values can also represent both letters and numbers. Fig. 4.10 represents the binary value of the letter “B” and also shows the breakdown of the nibble values for the same value representing the number 42.

How do computers convert binary to decimal?

Figure 4.9. Nibble to byte value example.

How do computers convert binary to decimal?

Figure 4.10. Binary to letter, Nibble to number example.

American Standard Code for Information Exchange

ASCII tables can reflect all 256 codes (0–255). There will be 95 printable codes. 52 are US English codes with 26 lowercase and 26 uppercase. The remaining codes represent codes from the decimal 128 decimal values. This is commonly referred to the extended table. The most common table is the ISO 8859-1 which is also called the ISO Latin-1. Fig. 4.11 shows an ASCII character to binary table example. Fig. 4.12 is an example of a standard ASCII decimal–hexadecimal–character example. These are just two examples and do not include values from the extended ASCII table.

How do computers convert binary to decimal?

Figure 4.11. Character to binary.

How do computers convert binary to decimal?

Figure 4.12. Decimal/hexadecimal/character.

Unicode

Another type of encoding that examiners may see is called Unicode. Languages other than English were limited to the 256 codes of the ASCII. They could not fit into this limited space and developers created Unicode. This creates a 2 bytes number for every character, no matter what language is used. Using 16 bits (2 bytes), 65,536 characters can be defined, whereas 256 possibilities were possible with 8 bits (1 byte). One way to quickly recognize Unicode is to look for the 00 padding between the bytes. Fig. 4.13 is an example of Unicode.

How do computers convert binary to decimal?

Figure 4.13. Unicode example.

Big and Little Endian

Additional formats called Big Endian (BE) and Little Endian (LE) relate to how data can be encoded. Both refer to a specific byte order. BE is the most significant byte being first while LE references the least significant byte being first. Both are read from left to right. Unicode can also have BE or LE byte order. Fig. 4.14 is an example of standard hexadecimal and Unicode.

How do computers convert binary to decimal?

Figure 4.14. Big/Little Endian examples (with Unicode).

Nibble Reversed

Nibble reversed is used to describe values that need to be switched in order to be decoded. This type of encoding can commonly be found in mobile file systems and is more prevalent in time some stamps. We will discuss in more detail about time stamps, but for now, Fig. 4.15 is an example to illustrate a nibbled reverse value from a Samsung GSM phone.

How do computers convert binary to decimal?

Figure 4.15. Six byte Nibble Reversed date and time stamp.

Seven-Bit Short Message Service Protocol Description Unit

Short message service protocol description unit (SMS PDU) is a message feature that uses 7 bits per character compared to 8 bits per character of traditional messaging. This efficiency allows 160 characters to fit into 140 bytes. This saves space during the sending and receiving of text messages.

When an SMS is sent, encoding and decoding must take place. PDU mode uses three special data types: ctet, semi-octet, and septet. 7-bit PDU uses 7-bit septet which has to be converted to the octet string to transfer through the network.

Fig. 4.16 is an example of the binary to lower character representation of the two words: “hellohello.” The table shows the lowercase letter at the top, the decimal version of the letter in the middle, followed below by the decimal 7-bit septet.

How do computers convert binary to decimal?

Figure 4.16. 7-bit septet short message service example.

This message (hellohello) consists of 10 characters, called septets when represented by 7 bits each. For SMS delivery, these septets need to be converted into 8-bit octets for the transfer. This takes place by adding the rightmost bit of the second septet. This bit is inserted into the first septet, 1+1101000 = 11101000 (E8). The rightmost bit of the second character is then consumed, so the second character needs 2 bits of the third character to make an 8-bit octet. This process continues until the entire string is complete and in the case of this example, has fitted the 10 septets into 9 octets. Fig. 4.17 shows the 7-bit septet hellohello SMS example being converted to 8-bit octet.

How do computers convert binary to decimal?

Figure 4.17. 7-bit septet conversion to 8-bit octet.

A completed 7-bit PDU message will generally have the SMS string, a time stamp, and the numbers involved in the message. If we take just the content of a PDU string, “Where did you bury the body?” This sentence would look like this: 00110000910000FF1C5774595E0691D36450FE5D0789EBF23C888E2E83C46F72FE07.

Read moreNavigate Down

View chapterPurchase book

Read full chapter

URL: https://www.sciencedirect.com/science/article/pii/B9780128033401000045

Comparative performance analysis of evolutionary algorithm based parameter optimization in cognitive radio engine: A survey

Pyari Mohan Pradhan, Ganapati Panda, in Ad Hoc Networks, 2014

6.1 Single carrier communication system

The performance of different algorithms in single carrier communication system is investigated in this sub-section. The CR scenario shown in Fig. 3 is considered. For this study, the number of generations is set to 100. Different results obtained with each algorithm are analyzed, depending on the mode of operation listed in Table 1. In each case, the results obtained from 30 independent experiments are reported.

How do computers convert binary to decimal?

Fig. 3. Co-existence scenario of primary and cognitive users in single carrier communication system undertaken for simulation study.

6.1.1 Emergency mode of operation

Fig. 4 shows the fitness convergence characteristics obtained with different algorithms in emergency mode of operation in the CR. It is observed that the convergence rate of all algorithms are almost similar in emergency mode for a single carrier communication system. The six EAs are able to converge to the optimal fitness with in 20 generations.

How do computers convert binary to decimal?

Fig. 4. Fitness convergence characteristics in emergency mode of operation in single carrier communication system.

Table 3 shows the optimal generation in which each algorithm reaches the optimal fitness value. The values of optimal fitness indicate that the six algorithms perform similarly in the emergency mode of operation for a single carrier communication system. The standard deviation for optimal fitness shows the consistency in the performance of each algorithm. However, when compared, the DE algorithm takes the highest number of generations to reach the optimal fitness. The computation time required to reach the optimal generation is also shown in Table 3 along with the number of fitness function evaluations carried out by each algorithm. The GA requires the highest computation time of 48 ms. The inherent feature of the GA, i.e. binary to decimal conversion and vice versa contributes to high computation time. The CSO requires only 0.1 ms to reach its optimal fitness. The BFO carries out the highest number of fitness function evaluations in order to reach its optimal fitness.

Table 3. Optimal fitness obtained and corresponding optimal generation, optimal computation time (in s) and optimal fitness function evaluation required by different algorithms in emergency mode of operation in single carrier communication system.

AlgorithmFitnessGenerationComp. TimeFunction evaluationsAvg.S.D.Avg.S.D.Avg.S.D.GA0.92370.0000a1940.04880.0371950PSO0.92370.0000a310.00300.0008150DE0.92350.0000a3230.01330.00783200BFO0.92370.0000a1740.00500.00304250ABC0.92370.0000a820.00050.0003406CSO0.92370.0000a310.00010.0000210

aValues less than 10-4have been displayed as 0.0000.

The high rate of convergence and low computation time in emergency mode facilitates the use of EAs in time variant wireless environment.

6.1.2 Low power mode of operation

Fig. 5 shows the fitness convergence characteristics obtained with different algorithms for low power mode of operation in the CR. In this mode, the rate of convergence of each algorithm is slower than their corresponding rate in emergency mode of operation shown in Fig. 4. It is also seen that the steady state value achieved in this mode is less than that achieved in emergency mode. This result is also verified by the values of optimal fitness shown in Table 4.

How do computers convert binary to decimal?

Fig. 5. Fitness convergence characteristics in low power mode of operation in single carrier communication system.

Table 4. Optimal fitness obtained and corresponding optimal generation, optimal computation time (in s) and optimal fitness function evaluation required by different algorithms in low power mode of operation in single carrier communication system.

AlgorithmFitnessGenerationComp. TimeFunction evaluationsAvg.S.D.Avg.S.D.Avg.S.D.GA0.88030.0000a1130.02990.0151550PSO0.89540.0000a4230.92240.05672100DE0.89510.0000a4440.02700.00804400BFO0.82710.01662840.03290.01537000ABC0.89540.0000a1760.00820.0019862CSO0.89540.0000a1640.00890.00081120

aValues less than 10-4have been displayed as 0.0000.

Table 4 reveals that, except the BFO, the other five algorithms perform approximately similar with respect to optimal fitness with very low values of standard deviation. The algorithms need more number of generations for local search near the global optima. Table 4 also shows the computation time required to reach the optimal generation. In this mode of operation, the PSO needs the highest computation time of 922 ms to reach its optimal fitness. Table 4 also shows that similar to emergency mode, the BFO carries out the highest number of fitness function evaluations in this mode to reach its optimal fitness.

6.1.3 Multimedia mode of operation

The fitness convergence characteristics in Fig. 6 shows that the rate of convergence of the six algorithms is high in multimedia mode of operation. It can be seen that the algorithms converge at a very high rate to a value of 0.9043.

How do computers convert binary to decimal?

Fig. 6. Fitness convergence characteristics in multimedia mode of operation in single carrier communication system.

The values of optimal fitness in Table 5 testify the convergence of each algorithm. Although the six algorithms perform similarly with respect to optimal fitness, the optimal generation required for each algorithm vary significantly. Similar to low power mode, the DE needs the highest number of generations to reach its optimal fitness in this mode. The computation time requirement along with the optimal number of fitness evaluations are listed in Table 5. In this mode, the PSO needs the highest computation time but the least number of fitness function evaluations to reach its optimal fitness.

Table 5. Optimal fitness obtained and corresponding optimal generation, optimal computation time (in s) and optimal fitness function evaluation required by different algorithms in multimedia mode of operation in single carrier communication system.

AlgorithmFitnessGenerationComp. timeFunction evaluationsAvg.S.D.Avg.S.D.Avg.S.D.GA0.90420.0000a820.03130.0308400PSO0.90430.0000a530.11610.0075250DE0.90430.0000a1930.01190.00481900BFO0.90430.0000a1220.01280.00613000ABC0.90430.0000a1040.00490.0027507CSO0.90430.0000a630.00320.0002420

aValues less than 10-4have been displayed as 0.0000.

The single carrier communication system involves only one carrier with two optimization parameters. Since the dimensionality of the problem is low, there are few possibilities of algorithms getting trapped in local optima. Due to the low complexity of the optimization problem, the EAs are able to optimize the parameters quickly to reach the global optima. Therefore, the performances of the six algorithms in single carrier communication system are similar with respect to the optimal fitness, but limited in terms of memory requirement and computation time. Looking at the performance of the six algorithms, the ABC can be considered as the best choice for any mode of operation in single carrier communication system. However, the selection of an algorithm for any application depends on the amount of resources available such as hardware memory and processor speed.

With the introduction of multicarrier communication systems, the use of single carrier systems are limited to few applications. In this study, the advantage of multicarrier communication systems over single carrier communication systems can be realized using the simulation results.