Exploring Number Bases: Converting Decimal to Binary, Octal, and Hex, Study notes of Computer Science

An in-depth exploration of number bases, focusing on converting decimal numbers to binary, octal, and hexadecimal. Learn the basics of positional notation, the relationship between different bases, and how to perform conversions using examples and formulas.

Typology: Study notes

2021/2022

Uploaded on 08/05/2022

dirk88
dirk88 🇧🇪

4.4

(222)

3.1K documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSE1520 W08 M. Mandelbaum book
slides Computer Science Illuminated 1
Chapter 2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download Exploring Number Bases: Converting Decimal to Binary, Octal, and Hex and more Study notes Computer Science in PDF only on Docsity!

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

Chapter 2

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

Chapter Goals „^ Know the different types of numbers „^ Describe positional notation „^ Convert numbers in other bases to base 10 „^ Convert base 10 numbers into numbers of otherbases „^ Describe the relationship between bases 2, 8,and 16 „^ Explain computing and bases that are powers of^2

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

Integers A natural number, a negative number, zeroExamples:

Numbers^ Rational Numbers^ An integer or the quotient of two integersExamples: -249, -1, 0, 3/7, -2/

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

How many ones are there in 642?

600 + 40 + 2? Or is it 384 + 32 + 2? Or maybe… 1536 + 64 + 2?

Natural Numbers

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

Continuing with our example…642 in base 10

positional notation

is:

6 x 10

2 = 6 x 100

  • 4 x 10

1 =^

4 x 10

  • 2 x 10º =

2 x 1

= 642 in base 10

This number is in base 10

The power indicatesthe position ofthe number

Positional Notation

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

d^ * Rn^

n-1^ + d

* Rn-^

n-2^ + ... + d

* R + d 2

1

As a formula: 642 is

+^2

R is the baseof the number^1

n is the number ofdigits in the number

d is the digit in thei

th^ positionin the number

Positional Notation

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

Decimal is base 10 and has 10 digits:

Binary is base 2 and has 2 digits:

Binary^ For a number to exist in a given number system,the number system must include those digits. Forexample, the number 284 only exists in base 9 andhigher.

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

How are digits in bases higher than 10represented?^ With distinct symbols for 10 and above.Base 16 has 16 digits:

0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F

Bases Higher than 10

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

What is the decimal equivalent of thehexadecimal number DEF?

D x 16

2 = 13 x 256 = 3328

  • E x 16

1 = 14 x 16 = 224

  • F x 16º = 15 x 1

= 15= 3567 in base 10

Converting Hexadecimal to DecimalRemember, the digits in base 16 are0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

14

What is the decimal equivalent of the binarynumber 1101110?

1 x 2

6 = 1 x 64 = 64

  • 1 x 2

5 = 1 x 32 = 32

  • 0 x 2

4 = 0 x 16 = 0

  • 1 x 2

3 = 1 x 8

  • 1 x 2

2 = 1 x 4

  • 1 x 2

1 = 1 x 2

  • 0 x 2º = 0 x 1

= 0= 110 in base 10

Converting Binary to Decimal

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

16

Remember borrowing?

Apply that concept

here:

Subtracting Binary Numbers

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

17

10 12 1010

9 11 1001

8 10 100

7 7 111

6 6 110

5 5 101

4 4 100

3 3 011

2 2 010

1 1 001

0 0 000

Decimal Octal Binary

Power of 2 Number System

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

19

  • Groups of Four (from right)• Convert each group

1010 1011A

B

10101011 is AB in base 16

Converting Binary to Hexadecimal

CSE1520 W08 M. Mandelbaum

book slides Computer Science Illuminated

20

While the quotient is

not

zero

Divide the decimal number by the new baseMake the remainder the next digit to the left inthe answerReplace the original dividend with the quotient

Algorithm for converting base 10 to otherbases

Converting Decimal to Other Bases