• No results found

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

N/A
N/A
Protected

Academic year: 2021

Share "Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems This assignment is designed to familiarize you with different numbering systems, specifically: binary, octal, hexadecimal (and decimal) and converting between them. This lab can be printed out directly or downloaded and printed. Click here for a printable PDF version of the lab. You can write your responses directly on the printed sheet. To print this sheet directly: make sure you have a printer available on your machine or network. In the browser, drag down the File menu and click on print. To download, drag down your browser’s File menu and select Save as… Then save the file with whatever name you wish to your machine. You can then print the file.

Note on formatting used below: 1 x 2 ^ 2 equals 1 times 2 raised to 2. The notation 1*2**2 is the same thing. You might see this in a computer language. In the spirit of being well- rounded both will be used here.

First, a quick review of how to do number conversions. Decimal: base 10 (0 1 2 3 4 5 6 7 8 9)

Binary: base 2 (0 1)

Octal: base 8 (0 1 2 3 4 5 6 7)

Hexadecimal: base 16 (0 1 2 3 4 5 6 7 8 9 A B C D E F) Our handy basic number conversion table:

Base 10 base 2 base 8 base 16 Decimal binary octal hex(adecimal)

0 0 0 0

1 1 1 1

2 10 2 2 (base 2 is at 2 digits already)

3 11 3 3

4 100 4 4

5 101 5 5

6 110 6 6

7 111 7 7

8 1000 10 8 (base 8 just went to 2 digits)

9 1001 11 9

--- (base 10 goes to two digits)

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

(2)

POWER (place) 4 3 2 1 0 Base 10 10000 1000 100 10 1 Base 2 16 8 4 2 1 Base 8 4096 512 64 8 1 Base 16 65536 4096 256 16 1 For example: POWER (place) 4 3 2 1 0 Final result in Decimal Base 10 of 10001 1 x 10 ^ 4 = 10,000 0 x 10 ^ 3 = 0 0 x 10 ^ 2 = 0 0 x 10 ^ 1 = 0 1 x 10 ^ 0 = 1 x 1 = 1 10000 + 0 + 0 + 0 + 1 = 10001 Base 2 of 10001 1 x 2 ^ 4 = 16 0 x 2 ^ 3 = 0 0 x 2 ^ 2 = 0 0 x 2 ^ 1 = 0 1 x 2 ^ 0 = 1 x 1 = 1 16 + 0 + 0 + 0 + 1 = 17 Base 8 of 10001 1 x 8 ^ 4 = 4096 0 x 8 ^ 3 = 0 0 x 8 ^ 2 = 0 0 x 8 ^ 1 = 0 1 x 8 ^ 0 = 1 x 1 = 1 4096 + 0 + 0 + 0 + 1 = 4097 Base 16 o 10001 1 x 16 ^ 4 = 65536 0 x 16 ^ 3 = 0 0 x 16 ^ 2 = 0 0 x 16 ^ 1 = 0 1 x 16 ^ 0 = 1 x 1 = 1 65536 + 0 + 0 + 0 + 1 = 65537

Going from binary/octal/hexadecimal to decimal:

An easy way to remember it: take the number and raise the base to the place binary to decimal example

101 = 1*2**2 + 0*2**1 + 1*2**0 = 4 + 0 + 1 = 5

That’s 1 times the base (of 2) raised to the place (2) PLUS 0 times the base (again, 2) raised to the place (1) PLUS 1 times the base (still 2) raised to the place (0)

octal to decimal example

15 = 1*8**1 + 5*8**0 = 8 + 5 = 13

That’s 1 times the base (of 8) raised to the place (1) PLUS 5 times the base (again, 8) raised to the place (0)

hex to decimal examples 10 = 1*16**1 + 0*16**0 = 16

(3)

That’s 1 times the base (of 16) raised to the place (1) PLUS 0 times the base (yup, 16) raised to the place (0).

1A = 1*16**1 + 10*16**0 = 26

That’s 1 times the base (of 16) raised to the place (1) PLUS 10 (A is 10 in decimal) times the base (of 16) raised to the place (0). With hex you have to remember what the decimal equivalent of the numbers are using our handy chart above.

Going from Decimal to Binary (and octal and hex)

One way is to work with the remainder – continually dividing the initial number and then resulting numbers by the base until it cannot be divided without fractions. Then take the remainders, beginning with the first one produced, and write them out from right to left. Example of decimal to binary:

Take the decimal number 100 to convert to binary.

The decimal number is divided by the base (2) to find the quotient and remainder. The number 100 / 2 = 50 with remainder of 0

The number 50 / 2 = 25 with remainder of 0 The number 25 / 2 = 12 with remainder of 1 The number 12 / 2 = 6 with remainder of 0 The number 6 / 2 = 3 with remainder of 0 The number 3 / 2 = 1 with remainder of 1 The number 1 / 2 = 0 with remainder of 1

Now from the top take the remainders and write from right to left (or from the bottom up and write left to right). That gives us the binary number: 1100100

Example of decimal to octal:

Take the decimal number 100 to convert to octal.

The decimal number is divided by the base (8) to find the quotient and remainder. The number 100 / 8 = 12 with remainder of 4

The number 12 / 8 = 1 with remainder of 4 The number 1 / 8 = 0 with remainder of 1

Now from the top take the remainders and write right to left. That gives us the octal number: 144

Another easy way for smaller numbers is using the place table. We know for each place in base 2 we are multiplying by two. We have:

(4)

Decimal Equivalent if “1” present 64 32 16 8 4 2 1 Total of all these numbers added together = 127 64 32 16 8 4 2 1 Binary equivalent (a 6 digit binary number) 1 1 1 1 1 1 1

So, for example, how would you represent 45 decimal in binary?

PLACE 6 5 4 3 2 1 0 Decimal Equivalent if “1” present 64 32 16 8 4 2 1 45 = these numbers added together 32 8 4 1 Binary equivalent, Binary:0101101 0 1 0 1 1 0 1

So, ever wonder why everything in computers is 16, 32, 64, 128, 256, 512, etc? Now it should be making a lot more sense. The computer, of course, is using binary numbers.

Going from binary to octal/hex and back (recall our basic conversion table)

Base 10 base 2 base 8 base 16 Decimal binary octal hex(adecimal)

0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 8 1000 10 8 9 1001 11 9 --- 10 1010 12 A 11 1011 13 B

(5)

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

Octal is every three bits starting from right- most digit. Example:

10010011 = 10 010 011 (grouping the digits three at a time from the right- most digit) NOW, simply find the octal value for each grouping of three in order from left and that is the final result–

BINARY 10 010 011 10010011

OCTAL 2 2 3 223

…you can do the same thing going backwards to binary.

Hex works the same way. But, it is every 4 bits starting from right-most digit. Example:

10010011 = 1001 0011

BINARY 1001 0011 10010011

OCTAL 9 3 93

Questions

Ok, time for you to do a little work. Use the number conversion program to check your answers. You must show your work.

1. Take the following decimal numbers and convert them to binary, octal and hexadecimal: 20 35 127 245 768

2. Take the following binary numbers and convert to octal, hex, and decimal: 011001

011101 0110 1010101

(6)

35 20 467

4. Take the following hex numbers and convert to binary and octal: 1F

FE A23 A1B2C3

References

Related documents

hospital) audit began with records from FY05-06. Myers & Stauffer is the contractor who sent surveys to hospitals to get information collected and reported. They are

Helpful information for converting ASCII decimal hexadecimal octal and binary values can be referenced in world table Table.. The conversion routines emulating

 こうした“Shelley’s defects”は Leigh Hunt の認めるところでもあった。 しかしその一方で彼は、この詩の批評において、政治詩人としての Shelley に 対

To convert a decimal number into its octal equivalent, the same procedure is adopted as in decimal to binary conversion but the decimal number is divided by 8 (the base of the

Implementation of device therapy (cardiac resynchronization therapy and implantable cardioverter defibrillator) for patients with heart failure in Europe: changes from 2004 to

The next subsection addresses the spatial scope of the marine Arctic, followed by subsection 2.3 on the Arctic Council and its constitutive instrument, subsection 2.4 on the

“If system B is used, Member States must achieve at least the same degree of differentiation as would be achieved using System A. Accordinly, the surface water bodies within the

As you have no doubt observed by this time, writing out and reading numbers in natural binary form is quite a nuisance because of the large number of digits involved.. Since it