Data, Representation & Numeracy, Slides of Computer Science

An overview of the fundamental concepts related to data representation and numeracy in computer systems. It covers the basic units of data organization (bits, bytes, words), binary coding for representing characters and numbers (including unsigned, signed, and floating-point representations), and techniques for converting between different number bases (decimal, binary, octal, hexadecimal). The document also discusses the relevance of these concepts to the design of digital circuits for computer memory, cpu, and arithmetic logic unit (alu) components. The content serves as an introduction to the underlying principles of how data is stored, manipulated, and processed in computer hardware and software.

Typology: Slides

2019/2020

Available from 09/27/2024

ali-rasheed-1
ali-rasheed-1 🇵🇰

3 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 1 – Part B
Data, Representation &
Numeracy
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Data, Representation & Numeracy and more Slides Computer Science in PDF only on Docsity!

Lecture 1 – Part B

Data, Representation &

Numeracy

Data, Representation & Numeracy

  • In order to understand how data is processed by computers it

is necessary to understand

  • what is data
  • how is data represented in computers
  • how is data manipulated and processed

Size terminology

  • The following prefix terms are used to denote timing interval

size (seconds):

  • 10

     milli 
  • 10

     micro 
  • 10

     nano 
  • 10

     pico 
  • 10

     femto 
  • The following prefix terms are used to denote storage device

size (bytes):

  • 2 10 kilo (1024)
  • 2 20 mega ( ~ 10 6 )
  • 2 30 giga ( ~ 10 9 )
  • 2 40 tera ( ~ 10 12 )
  • 2 50 peta ( ~ 10 15 )

Binary Coding

  • Binary, or base-2, coding is used for all data in the computer
  • 2-state switches
    • only 0 and 1 are used as values
    • each corresponds to a specific electrical (magnetic/optical) signal value
  • Characters
    • the ASCII system is used to represent printable characters and also some non-printable signals used in inter-computer communication across networks
  • Numbers
    • unsigned integer
    • signed integer
    • real, or floating point, numbers
    • decimal (base-10) numbers are also used in computers

Positional Representation (2)

  • In a system based on a different multiplier, or radix (we say, “base

-R”) we may represent a general, positive number N in the form:

N = d

L-

d

L-

… d

2

d

1

d

0

. f

1

f

2

… f

M

where each d or f represents a single digit, but now the concept

and representation of digit takes on a new meaning.

  • This can be rewritten in the form:

L-1 M

N = Sum dk * R

k

+ Sum fk * R

-k

; 0 ≤ dk , fk < R

k=0 k=

  • This representation still permits us to perform the basic arithmetic

operations as we did for decimal arithmetic!

Unsigned Binary

  • Non-negative integers (greater or equal to zero)
    • Range from 0 (smallest) to 2 L -1 (largest) for an L-bit representation
  • We can construct an unsigned binary sequence using the

algorithm

  • Build up starting from 0.
  • Add 1 to the previous number.
  • Repeat previous step until a string of 1’s of length L is reached. Binary Dec. Binary Dec. 0111 7 1111 15 0110 6 1110 14 0101 5 1101 13 0100 4 1100 12 0011 3 1011 11 0010 2 1010 10 0001 1 1001 9 0000 0 1000 8

Signed Binary - 1’s complement

  • In most cases we require both positive and negative integers
  • One idea for “designing” negative numbers uses complementation
    • change 0’s to 1’s and 1’s to 0’s
  • Values range from - L- +1 (most negative) to 2 L- -1 (largest, most positive) for an L-bit representation.
  • Permits two different representations of zero! Binary Dec. Binary Dec. 0111 7 1000 - 0110 6 1001 - 0101 5 1010 - 0100 4 1011 - 0011 3 1100 - 0010 2 1101 - 0001 1 1110 - 0000 0 1111 -

Signed Binary - 2’s complement

  • We need a more efficient representation of positive and

negative integers using an L-bit form.

  • One straightforward approach is to consider the operation:

X

+ Y

0 What representation of Y gives a zero sum?

**00000011

  • bbbbbbb 00000000 3 Y**

Signed Binary - 2’s complement

  • We need a more efficient representation of positive and

negative integers using an L-bit form.

  • The 2’s complement scheme is based on the algorithm:
      1. Find the 1’s complement
      1. Add 1 to the result to find the 2’s complement form. **3 00000011 ~3 11111100
  • 1 -3 11111101 2 1**

(r-1)’s and r’s complements

  • In an arbitrary radix of fixed (finite) representation length L,

there are two related complements that are important.

  • (r-1)’s complement form.
    • Given the number N in radix-r form, the (r-1)’s complement is defined as r L^ – 1 – N
    • Consider r = 10, L = 4 and N = 2468. Clearly, r 4 = 10000, thus r 4 – 1 = 9999. Thus, **9999
  • 2468 7531 Easy!**
    • Note that the sum of N and the (r-1)’s complement of N is always a string of (r- 1)’s (9 in this example).
  • r’s complement form
    • The r’s complement is found from the (r-1)’s complement by just adding 1.
    • Note that this guarantees that the sum of N and its r’s complement is just zero (0) to within the size L of the representation!

Subtraction of unsigned Numbers

  • Example: M < N, L=5 ( M = 13250, N = 72532)

Borrowing: 13250 10’s Compl.: 13250

- 72532 + 27467

Find 10’s compl., add minus

Final Answer: - 59282

Converting between arbitrary bases

  • Consider the problem of converting the number 15310 into its equivalent number in base-.
  • Although this may seem strange at first, it is solved by repeatedly dividing 153 (and successive quotients) by 13 and collecting remainders, hence:
  • 13 into 153 11 10 (A) 0 11 (B) ANSWER: BA
  • Problem: What is the radix of the integer numbers (coefficients) below if the solution to the quadratic equation shown is x=5? x 2 **- 12 x + 39 = 0 Substituting x = 5 and expanding the positional representations of each coefficient: 5 2
  • ( 1R + 2 ) * 5 + ( 3R + 9 ) = 25 – 5R – 10 + 3R + 9 = 24 – 2R = 0 It follows from the last step that R = 12. WARNING: Converting to arbitary bases may be quite difficult. If terms up to R 4 arise (a quartic equation) it can be solved exactly, but not for higher powers. Such problems require brute force.*

Floating Point

  • Use scientific notation to represent the
    • sign
    • fraction (mantissa)
    • exponent sign exponent fraction 0 + (2’s compl.) 1 - When the leftmost (ie. most significant) fraction bit is one (1) the fraction is called normalized; otherwise it is unnormalized. Note that the exponent may be positive or negative. We use the 2’s complement form. The exponent is then called the characteristic.

Binary Coded Decimal (BCD)

  • Many computers contain logic to process decimal

representations directly.

  • The standard representation is based on an ASCII-compatible

scheme for each separate decimal digit. This is called the

BCD scheme.

  • Note that a minimum of 4 bits is required to represent all 10

decimal digits.

0 0000 5 0101 1 0001 6 0110 2 0010 7 0111 3 0011 8 1000 4 0100 9 1001