data representation in computer systems, Study notes of Computer Science

lecture notes for first year students in computer engineering and electrical engineering field

Typology: Study notes

2017/2018

Uploaded on 05/17/2018

computer-science-ub
computer-science-ub 🇨🇲

1 document

1 / 80

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Chapter 5
Data 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
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50

Partial preview of the text

Download data representation in computer systems and more Study notes Computer Science in PDF only on Docsity!

Chapter 5

Data representation

Learning outcomes

 By the end of this Chapter you will be able to:

  • Explain how integers are represented in computers using:
    • Unsigned, signed magnitude, excess, and two’s complement notations
  • Explain how fractional numbers are represented in computers
    • Floating point notation (IEEE 754 single format)
  • Calculate the decimal value represented by a binary sequence in:
    • Unsigned, signed notation, excess, two’s complement, and the IEEE 754 notations.
  • Explain how characters are represented in computers
    • E.g. using ASCII and Unicode
  • Explain how colours, images, sound and movies are represented

Introduction

 In Chapter 3

  • How information is stored
    • in the main memory,
    • magnetic memory,
    • and optical memory

 In Chapter 4:

  • We studied how information is processed in computers
  • How the CPU executes instructions

 In Chapter 5

  • We will be looking at how data is represented in computers
  • Integer and fractional number representation
  • Characters, colours and sounds representation

Binary numbers

 Binary number is simply a number comprised of only 0's and 1's.

 Computers use binary numbers because it's easy for them to communicate using electrical current -- 0 is off, 1 is on.

 You can express any base 10 (our number system -- where each digit is between 0 and 9) with binary numbers.

 The need to translate decimal number to binary and binary to decimal.

 There are many ways in representing decimal number in binary numbers. (later)

Example

  •  3040510 = 30000 + 400 +
    • = 310^4 +410^2 +5*10
  •  101012 =10000+100+
    • =12^4 +12^2 +1*2

Examples: decimal -- binary

 Find the binary representation of 12910.

 Find the decimal value represented by

the following binary representations:

  • 10000011
  • 10101010

Number representation

 Representing whole numbers

 Representing fractional numbers

Integer Representations

  • Unsigned notation
  • Signed magnitude notion
  • Excess notation
  • Two’s complement notation.

Advantages and disadvantages of

unsigned notation

 Advantages:

  • One representation of zero
  • Simple addition

 Disadvantages

  • Negative numbers can not be represented.
  • The need of different notation to represent negative numbers.

Representation of negative

numbers

 Is a representation of negative numbers

possible?

 Unfortunately:

  • you can not just stick a negative sign in front of a binary

number. (it does not work like that)

 There are three methods used to represent

negative numbers.

  • Signed magnitude notation
  • Excess notation notation
  • Two’s complement notation

Example

 Suppose 10011101 is a signed magnitude representation.

 The sign bit is 1, then the number represented is negative

 The magnitude is 0011101 with a value 2^4 +2^3 +2^2 +2^0 = 29

 Then the number represented by 10011101 is – 29.

position 7 6 5 4 3 2 1 0 Bit pattern 1 0 0 1 1 1 0 1

contribution - 24 23 22 20

Exercise 1

  1. 3710 has 0010 0101 in signed magnitude notation. Find the signed magnitude of – 3710?
  2. Using the signed magnitude notation find the 8-bit binary representation of the decimal value 24 10 and -
  3. Find the signed magnitude of – 63 using 8-bit binary sequence?

Signed-Summary

 In signed magnitude notation,

  • The most significant bit is used to represent the sign.
  • 1 represents negative numbers
  • 0 represents positive numbers.
  • The unsigned value of the remaining bits represent The magnitude.

 Advantages:

  • Represents positive and negative numbers

 Disadvantages:

  • two representations of zero,
  • Arithmetic operations are difficult.

Excess Notation

 In excess notation:

  • The value represented is the unsigned value with a fixed value subtracted from it. - For n-bit binary sequences the value subtracted fixed value is 2 (n-1).
  • Most significant bit:
    • 0 for negative numbers
    • 1 for positive numbers