Binary to Decimal and Hexadecimal Conversion

Written on 09:29 by Ahmet Emir


Before we accomplishment this affiliate and move to discussing the TCP/IP agreement assemblage and IP addressing

in Affiliate 2, it’s absolutely important for you to absolutely accept the differences between

binary, decimal, and hexadecimal numbers and how to catechumen one architecture into the other.

Each articulation has its own blow domain.

All segments are in the aforementioned advertisement domain.

1 2 3 4

The OSI Reference Model 27

So we’ll alpha with bifold numbering. It’s appealing simple, really. The digits acclimated are bound to

either a 1 (one) or a 0 (zero), and anniversary chiffre is alleged 1 bit (short for bifold digit). Typically, you

count either 4 or 8 $.25 together, with these actuality referred to as a crumb and a byte, respectively.

What interests us in bifold calculation is the amount represented in a decimal format—the

typical decimal architecture actuality the base-10 cardinal arrangement that we’ve all acclimated back kindergarten.

The bifold numbers are placed in a amount spot: starting at the appropriate and affective left, with

each atom accepting bifold the amount of the antecedent spot.

Table 1.1 shows the decimal ethics of anniversary bit area in a crumb and a byte. Remember,

a crumb is 4 $.25 and a byte is 8 bits.

What all this agency is that if a one chiffre (1) is placed in a amount spot, afresh the crumb or byte

takes on that decimal amount and adds it to any added amount spots that accept a 1. And if a aught (0)

is placed in a bit spot, you don’t calculation that value.

Let me analyze things. If we accept a 1 placed in anniversary atom of our nibble, we would afresh add

up 8 + 4 + 2 + 1, to accord us a best amount of 15. Addition archetype for our crumb values

would be 1010; that agency that the 8 bit and the 2 bit are angry on, which equals a decimal

value of 10. If we accept a crumb bifold amount of 0110, afresh our decimal amount would be 6,

because the 4 and 2 $.25 are angry on.

But the byte ethics can add up to a amount that’s decidedly college than 15. This is how:

If we counted every bit as a one (1), afresh the byte bifold amount would attending like this (remember,

8 $.25 according a byte):

11111111

We would afresh calculation up every bit atom because anniversary is angry on. It would attending like this,

which demonstrates the best amount of a byte:

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

There are affluence of added decimal ethics that a bifold cardinal can equal. Let’s work

through a few examples:

10010110

Which $.25 are on? The 128, 16, 4, and 2 $.25 are on, so we’ll aloof add them up: 128 + 16 + 4

+ 2 = 150.

01101100

Which $.25 are on? The 64, 32, 8, and 4 $.25 are on, so we aloof charge to add them up: 64 + 32

+ 8 + 4 = 108.

11101000

Which $.25 are on? The 128, 64, 32, and 8 $.25 are on, so aloof add the ethics up: 128 + 64 +

32 + 8 = 232.

TABLE 1 . 1 Bifold Values

Nibble Ethics Byte Values

8 4 2 1 128 64 32 16 8 4 2 1

28 Affiliate 1  Internetworking

Table 1.2 is a table you should acquire afore braving the IP sections in Chapters 2 and 3.

Hexadecimal acclamation is absolutely altered than bifold or decimal—it’s adapted by

reading nibbles, not bytes. By application a nibble, we can catechumen these $.25 to hex appealing simply. First,

understand that the hexadecimal acclamation arrangement uses alone the numbers 0 through 9. And

since the numbers 10, 11, 12, and so on can’t be acclimated (because they are two-digit numbers), the

letters A, B, C, D, E, and F are acclimated to represent 10, 11, 12, 13, 14, and 15, respectively.

Hex is abbreviate for hexadecimal, which is a calculation arrangement that uses the first

six belletrist of the alphabet (A through F) to extend above the accessible 10 digits

in the decimal system. Hexadecimal has a absolute of 16 digits.

Table 1.3 shows both the bifold amount and the decimal amount for anniversary hexadecimal digit.

TABLE 1 . 2 Bifold to Decimal Memorization Chart

Binary Amount Decimal Value

10000000 128

11000000 192

11100000 224

11110000 240

11111000 248

11111100 252

11111110 254

11111111 255

TABLE 1 . 3 Hex to Bifold to Decimal Chart

Hexadecimal Amount Bifold Amount Decimal Value

0 0000 0

1 0001 1

2 0010 2

The OSI Reference Model 29

Did you apprehension that the aboriginal 10 hexadecimal digits (0–9) are the aforementioned amount as the decimal

values? If not, attending again. This accessible actuality makes those ethics cool accessible to convert.

So accept you accept article like this: 0x6A. (Sometimes Cisco brand to put 0x in

front of characters so you apperceive that they are a hex value. It doesn’t accept any added special

meaning.) What are the bifold and decimal values? All you accept to bethink is that each

hex appearance is one crumb and two hex characters calm accomplish a byte. To amount out

the bifold value, we charge to put the hex characters into two nibbles and afresh put them

together into a byte. 6 = 0110 and A (which is 10 in hex) = 1010, so the complete byte

would be 01101010.

To catechumen from bifold to hex, aloof booty the byte and breach it into nibbles. Here’s what I mean.

Say you accept the bifold cardinal 01010101. First, breach it into nibbles—0101 and

0101—with the amount of anniversary crumb actuality 5 back the 1 and 4 $.25 are on. This makes the

hex acknowledgment 0x55. And in decimal format, the bifold cardinal is 01010101, which converts

to 64 + 16 + 4 + 1 = 85.

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

8 1000 8

9 1001 9

A 1010 10

B 1011 11

C 1100 12

D 1101 13

E 1110 14

F 1111 15

TABLE 1 . 3 Hex to Bifold to Decimal Chart (continued)

Hexadecimal Amount Bifold Amount Decimal Value

30 Affiliate 1  Internetworking

Here’s addition bifold number:

11001100

Your acknowledgment would be 1100 = 12 and 1100 = 12 (therefore, it’s adapted to CC in hex). The

decimal about-face acknowledgment would be 128 + 64 + 8 + 4 = 204.

One added example, afresh we charge to get alive on the Physical layer. Accept you had the

following bifold number:

10110101

The hex acknowledgment would be 0xB5, back 1011 converts to B and 0101 converts to 5 in hex value. The

decimal agnate is 128 + 32 + 16 + 4 + 1 = 181.

If you enjoyed this post Subscribe to our feed

No Comment

Yorum Gönder