Docsity

data representation in computer systems, Study notes of Computer Science

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