number system in computers, Slides of Computer Science

interconverion of different types of numbers

Typology: Slides

2017/2018

Uploaded on 11/10/2018

neeladri
neeladri ๐Ÿ‡ฎ๐Ÿ‡ณ

4 documents

1 / 56

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Number
Representation
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38

Partial preview of the text

Download number system in computers and more Slides Computer Science in PDF only on Docsity!

Number

Representation

Number System :: The Basics

n We are accustomed to using the so-called

decimal number system

ยจ Ten digits :: 0,1,2,3,4,5,6,7,8,

ยจ Every digit position has a weight which is a

power of 10

ยจ Base or radix is 10

Example:

234 = 2 x 10

2

+ 3 x 10

1

+ 4 x 10

0

250.67 = 2 x 10

2

+ 5 x 10

1

+ 0 x 10

0

+ 6 x

  • 1

+ 7 x 10

  • 2

Positional Number Systems (General)

Decimal Numbers:

v 10 Symbols {0,1,2,3,4,5,6,7,8,9}, Base or Radix is 10 v 136.25 = 1 ยด^ **10 2

  • 3** ยด^ **10 1
  • 6** ยด^ **10 0
  • 2** ยด^ 10

- 1 + 3 ยด^ 10 - 2

Positional Number Systems (General)

Decimal Numbers:

v 10 Symbols {0,1,2,3,4,5,6,7,8,9}, Base or Radix is 10 v 136.25 = 1 ยด^ **10 2

  • 3** ยด^ **10 1
  • 6** ยด^ **10 0
  • 2** ยด^ 10

- 1 + 3 ยด^ 10 - 2

Binary Numbers:

v 2 Symbols {0,1}, Base or Radix is 2 v 101.01 = 1 ยด^ **2 2

  • 0** ยด^ **2 1
  • 1** ยด^ **2 0
  • 0** ยด^ 2

- 1 + 1 ยด^ 2 - 2

Positional Number Systems (General)

Decimal Numbers:

v 10 Symbols {0,1,2,3,4,5,6,7,8,9}, Base or Radix is 10 v 136.25 = 1 ยด^ **10 2

  • 3** ยด^ **10 1
  • 6** ยด^ **10 0
  • 2** ยด^ 10

- 1 + 3 ยด^ 10 - 2

Binary Numbers:

v 2 Symbols {0,1}, Base or Radix is 2 v 101.01 = 1 ยด^ **2 2

  • 0** ยด^ **2 1
  • 1** ยด^ **2 0
  • 0** ยด^ 2

- 1 + 1 ยด^ 2 - 2

Octal Numbers:

v 8 Symbols {0,1,2,3,4,5,6,7}, Base or Radix is 8 v 621.03 = 6 ยด^ **8 2

  • 2** ยด^ **8 1
  • 1** ยด^ **8 0
  • 0** ยด^ 8

- 1 + 3 ยด^ 8 - 2

Hexadecimal Numbers:

v 16 Symbols {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}, Base is 16 v 6AF.3C = 6 ยด^ **16 2

  • 10** ยด^ **16 1
  • 15** ยด^ **16 0
  • 3** ยด^ 16

- 1 + 12 ยด^ 16 - 2

Binary-to-Decimal Conversion

n Each digit position of a binary number has a weight

ยจ Some power of 2

n A binary number:

B = b

n- 1

b

n- 2

โ€ฆ..b

1

b

0

. b

  • 1

b

  • 2

โ€ฆ.. b

  • m Corresponding value in decimal: D = S b i 2 i i = - m n- 1

Decimal to Binary: Integer Part

nConsider the integer and fractional parts separately.
nFor the integer part:

nRepeatedly divide the given number by 2, and go on accumulating the remainders, until the number becomes zero. nArrange the remainders in reverse order. 2 89 2 44 1 2 22 0 2 11 0 2 5 1 2 2 1 2 1 0 0 1 Base NumbRem (89) 10 = (1011001) 2

Decimal to Binary: Integer Part

nConsider the integer and fractional parts separately.
nFor the integer part:

nRepeatedly divide the given number by 2, and go on accumulating the remainders, until the number becomes zero. nArrange the remainders in reverse order. 2 89 2 44 1 2 22 0 2 11 0 2 5 1 2 2 1 2 1 0 0 1 Base NumbRem (89) 10 = (1011001) 2 2 66 2 33 0 2 16 1 2 8 0 2 4 0 2 2 0 2 1 0 0 1 (66) 10 = (1000010) 2

Decimal to Binary: Fraction Part nRepeatedly multiply the given fraction by 2. nAccumulate the integer part (0 or 1). nIf the integer part is 1, chop it off. nArrange the integer parts in the order they are obtained.

Example: 0.

.634 x 2 = 1. .268 x 2 = 0. .536 x 2 = 1. .072 x 2 = 0. .144 x 2 = 0. : : (.634) 10 = (.10100โ€ฆโ€ฆ) 2

Decimal to Binary: Fraction Part nRepeatedly multiply the given fraction by 2. nAccumulate the integer part (0 or 1). nIf the integer part is 1, chop it off. nArrange the integer parts in the order they are obtained.

Example: 0.

.634 x 2 = 1. .268 x 2 = 0. .536 x 2 = 1. .072 x 2 = 0. .144 x 2 = 0. : : (.634) 10 = (.10100โ€ฆโ€ฆ) 2

Example: 0.

.0625 x 2 = 0. .1250 x 2 = 0. .2500 x 2 = 0. .5000 x 2 = 1. (.0625) 10 = (.0001) 2

Hexadecimal Number System

n A compact way of representing binary numbers
n 16 different symbols (radix = 16)
0 ร  0000 8 ร  1000
1 ร  0001 9 ร  1001
2 ร  0010 A ร  1010
3 ร  0011 B ร  1011
4 ร  0100 C ร  1100
5 ร  0101 D ร  1101
6 ร  0110 E ร  1110
7 ร  0111 F ร  1111

Binary-to-Hexadecimal

Conversion

n For the integer part,

ยจ Scan the binary number from right to left
ยจ Translate each group of four bits into the
corresponding hexadecimal digit
n Add leading zeros if necessary

n For the fractional part,

ยจ Scan the binary number from left to right
ยจ Translate each group of four bits into the
corresponding hexadecimal digit
n Add trailing zeros if necessary

Hexadecimal-to-Binary

Conversion

n Translate every hexadecimal digit into its 4 - bit binary equivalent n Examples:

(3A5)

16

2

(12.3D)

16

2

16

2

Unsigned Binary Numbers

n An n-bit binary number

B = b

n- 1

b

n- 2

โ€ฆ. b

2

b

1

b

0

n 2

n

distinct combinations are possible, 0 to 2

n

n For example, for n = 3, there are 8 distinct

combinations

n Range of numbers that can be represented

n=8 รจ 0 to 2

8

  • 1 (255)

n=16 รจ 0 to 2

16

  • 1 (65535)

n=32 รจ 0 to 2

32

  • 1 (4294967295)