**Home** / **converting a number to binary** / CS & IT Conversions

CS & IT Conversions

There are several number systems that you will use when working with computers. These

include decimal, binary, octal, and hexadecimal. Knowing how to convert between these

number systems is very important. Note: All the following number systems will explain only

positive integers unless otherwise stated.

Decimal (Base 10)

Decimal or base 10 is the number system that is normally used. The digits 0-9 are used to

write all numbers. Reviewing how decimal works will make working in other number

systems easier. In decimal, each place has a value or magnitude; for example, tens place and

ones place. Each place is a power of 10. See Example 1. All number systems follow this

same format.

Example 1: 25,198

Magnitude as 104 103 102 101 100

Powers of Ten

Magnitude 10,000 1,000 100 10 1

2 5 1 9 8

So the number 25,198 is the same as:

? 2 * 104 + 5 * 103 + 1 * 102 + 9 * 101 + 8 * 100

? 2 * 10,000 + 5 * 1,000 + 1 * 100 + 9 * 10 + 8 * 1

? 20,000 + 5,000 + 100 + 90 + 8

Unsigned Binary (Base 2)

The difference between unsigned binary and decimal is that you have only two digits that are

used to make up all binary numbers instead of ten. The two digits in binary are 0 and 1. The

place values are powers of two instead of powers of ten. Just as decimal has 100 at the right

most place, binary has 20 at the right most place. Just as decimal has 101 one place left of 100,

binary has 21 one place left of 20.

Example 2: Convert the unsigned binary number 101 to decimal.

Magnitude as Powers 22 21 20

of 2

Magnitude 4 2 1

1 0 1

The binary number 101 is the same as these values in decimal:

? 1 * 22 + 0 * 21 + 1 * 20

? 1*4+0*2+1*1

? 4+0+1

The binary number 101 is 5 in decimal.

CS & IT Conversions

Provided by the Academic Center for Excellence 1 Reviewed June 2008

To convert from decimal to unsigned binary, again use the magnitude of each place value in

binary. Start by writing out the magnitudes of binary until you write a value that is larger than

the number you are trying to write. Then subtract the largest magnitude that is smaller than

the number you are converting to decimal from the number you are converting to decimal.

Place a one under that magnitude and repeat until you have 0. Then fill in any empty spaces

with zeros.

124

- 64

Example 3: Convert 124 to unsigned binary. 60

- 32

Magnitude 128 64 32 16 8 4 2 1 28

1 1 1 1 1 0 0 - 16

12 124 is

1111100 in unsigned binary. - 8

4

- 4

0

Example 4: Convert 65 to unsigned binary.

Magnitude 128 64 32 16 8 4 2 1 65

1 0 0 0 0 0 1 - 64

1

65 is 1000001 in unsigned binary. - 1

0

Octal (Base 8)

With octal you have 8 digits, the numbers 0-7, and the place values are the powers of 8.

Example 5: Convert 34158 to decimal.

(When you see a subscript as in this example, it tells you which

number system the number is in. In this case 8 represents base 8 or

octal.)

Magnitude as 83 82 81 80

Powers of 8

Magnitude 512 64 8 1

3 4 1 5

34158 is the same as these values in decimal:

? 3 * 83 + 4 * 82 + 1 * 81 + 5 * 80

? 3 * 512 + 4 * 64 + 1 * 8 + 5 * 1

? 1536 + 256 + 8 + 5

? 1805

Provided by the Academic Center for Excellence 2 CS & IT Conversions

To convert from decimal to octal, the steps are similar as converting from decimal to binary.

First, write out the magnitudes of octal until you write a magnitude that is larger than the

number you are converting. Next, divide the number you are converting by each magnitude.

Write the integer part of the quotient under the magnitude. Then multiply the magnitude

and the integer part of the quotient under it. Next, subtract the product from the number

you are converting. Repeat this process until you have zero.

Example 6: Convert 197 to octal.

Step 1: 197/512 = 0 R 197

Magnitude 512 64 8 1

0

Step 2: 197/64 = 3 R 5 197

64 * 3 = 192 - 192

5

Magnitude 512 64 8 1

0 3

Step 3: 5/8 = 0 R 5 5

8*0=0 - 0

5

Magnitude 512 64 8 1

0 3 0

Step 4: 5/1 = 5 5

1*5=5 - 5

0

Magnitude 512 64 8 1

0 3 0 5

So 197 is 3058 in octal.

Hexadecimal (Base 16)

Provided by the Academic Center for Excellence 3 CS & IT Conversions

How do you change numbers to binary? To convert a decimal number to binary floating point representation: Convert the absolute value of the decimal number to a binary integer plus a binary fraction. Normalize the number in binary scientific notation to obtain m and e. Set s=0 for a positive number and s=1 for a negative number.

Title: Document Title

Subject:

Keywords:

Author: gcdavic

Creator: Acrobat PDFMaker 18 for Word

Producer: GPL Ghostscript 9.23

CreationDate: Thu Apr 26 18:38:09 2018

ModDate: Thu Apr 26 18:38:09 2018

Tagged: no

Form: none

Pages: 11

Encrypted: no

Page size: 612 x 792 pts (letter) (rotated 0 degrees)

File size: 156069 bytes

Optimized: no

PDF version: 1.4