Number Representation - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Number Representation

Description:

At least several basic kinds of information concepts: Annual earnings of a UT ... Compactness - compact data representation requires less storage space and less ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 29
Provided by: stevens66
Category:

less

Transcript and Presenter's Notes

Title: Number Representation


1
Number Representation
2
Representing Concepts
  • How do humans represent concepts?
  • At least several basic kinds of information
    concepts
  • Annual earnings of a UT faculty member.
    (numeric)
  • Script of Gone with the Wind. (characters)
  • Set of fingerprints on file in a police
    department. (visual)
  • John Hartford song. (audio)
  • We want a single, common way to represent.
  • Can be encoded as numbers, which in turn can
    appear as signals at the hardware level.

3
(No Transcript)
4
Number Representation
Any numbering system will consist of a number of
symbols with each symbol representing specific
elementary (face) values.
The Arabic system that we commonly use consists
of exactly ten symbols 0 1 2 3 4 5 6
7 8 9
The exact value of a symbol is determined by the
position (place) it occupies. This is the basis
of a positional numbering system.
The total value of a number is then the sum of
face values multiplied by their place values.
5
Decimal Numbering System
The Arabic numbering system uses ten symbols and
is a base ten numbering system. In any numbering
system the base is raised to consecutive powers
to determine positional (place) values.
103 102 101 100 basepowers
1000 100 10 1 place values 2 3 1 4 1 3 7 8 6
0
6
Alternative Systems
Suppose we only had one arm with five fingers.
Our numbering (base 5) system might then be based
on five symbols (0 1 2 3 4).
54 53 52 51 50 basepowers 625 125 25 5 1 pl
ace values 2 1 1 five _______
ten 4 0 3 five _______ ten
7
Computer RepresentationBinary System
At the hardware level computers must store
numbers using either the presence or absence of a
voltage. Then there are only two states
(symbols) available for number representation.
So base 2 (binary) is a suitable system for
computers.
26 25 24 23 22 21 20 basepowers 64 32 16 8 4 2 1
place values
8
Positional Systems
What value does 1110 represent?
Undetermined until the numbering system base is
stated.
  • Base 10 place values 10,000 1,000 100 10 1
  • Base 5 place values 625 125 25 5 1
  • Base 2 place values 16 8 4 2 1
  • 1 1 1 0 base x
  • base base 10
  • 10? 11000 1100 110 01 1,110
  • 5?
  • 2?

1125 125 15 01 155
18 14 12 01 14
9
Converting a decimal number ? base x number
  • Determine symbols (face values) used in base x.
  • Find place values for base x.
  • Start far left as necessary, try largest face
    value does it fit? If not, try next smallest
    face value. If it fits, how many face values can
    be accommodated. Repeat for next lowest place
    value.
  • Eg how is 5310 represented in base 2?

1
1
1
1
0
0
10
Bits, Bytes, and Words
Information in the computer are stored as a
groups of binary digits. An individual digit is
called a bit. Bits are grouped into 8-bit
collections called bytes. Memory is normally
measured in terms of bytes. Bytes are further
grouped into 4 or more byte groupings to make up
a computer word. The most common word size in
most modern computers is 32 bits (4 8-bit bytes)
Many programs do scientific calculations using
double (64-bit) words. What is the largest
integer value that can be expressed in 32 bits?
11
32-bit Unsigned Integers
Maximum Value
11111111111111111111111111111111 232-1
4,294,967,295
12
Three Representations of Signed(/-) Binary
Integers
  • Signed Magnitude Leading bit represents sign
    and remaining bits represent the corresponding
    unsigned number.
  • Ones Complement Negative representation is
    obtained by flipping all the bits of the unsigned
    number.
  • Twos Complement Negative representation is
    obtained by flipping all the bits and adding one.

13
Positive/Negative Integers
14
Examples Finding the Negative of Signed 8-bit
numbers
15
Binary Arithmetic
  • There are three simple rules for binary
    summation
  • 0 0 0
  • 0 1 1
  • 1 1 10

1 010110112 001000102
011111012

16
Twos Complement Arithmetic
Lets look at the simple 4 bit example of 2s
complement numbers. Suppose we wish to calculate
2-8. Twos complement allows us to do this via 2
(-8).
10102 01012 12 01102
00102 10002 10102

-6
Subtraction is accomplish using addition!
17
Range of 32-bit 2s Complement Integers
Maximum 01111111111111111111111111111111 2,147,48
3,647 231-1 Minimum 100000000000000000000000
00000000 -2,147,483,648 231
18
Decimal to Binary Fractions
To convert decimal fractions to binary fraction,
continually multiply fraction by base (2). The
integer parts of the results give the digits from
left to right.
19
Floating Point Numbers
First look at 0.1 in binary 0.0001100110011001100
11001100110110110 This is equal
to 1.100110011001100110011001100110011 x
2-4 Must store both exponent with its sign and
the mantissa (with sign).
20
Floating Point Numbers
Use 8 bits for exponent and its sign and 24 bits
for the mantissa and its sign. Internal
representation of 0.1 is then -0000100
10011001100110011001100 Converting this stored
number back to decimal gives 0.0999999940395355
Thus there is round-off error incurred when
storing floating point numbers 32-bit
representation.
21
Computer Representation of Real (floating point)
Numbers
Floating-point representation
m be
exponent (integer)
mantissa
base (10 or 8 or 2)
e.g. 156.78 is 1.5678x102
e.g. 0.0294 is 2.94x10-2
22
Number Representation(16-bit example)
Note limited number of digits to represent
mantissa
Sign of number
1
0
0
0
0
0
0
0
0
0
0
mantissa
exponent (with sign)
real numbers
0.0 1.0
23
Floating Point Representations
Exponent(24-31)
Fraction (123)
Sign (32)
Floating Point Value (-1)sign (1.Fraction)2
2(Exponent 0111 1111)
0111 1111(2) 127(10)
RED Built-in Values
24
32-bit Computers
  • 1-bit for the sign
  • 8-bits for the exponent (including its sign)
  • 23-bits for the mantissa

Exponent(24-31)
Fraction (123)
Sign (32)
The mantissa is always expressed as a binary
fraction
20 2-1 2-2 2-3 0 . 0 1 1 0.25 0.125
0.375
25
Real RepresentationProblem 1
The use of only a small number of bits to store
exponent gives a finite number of negative and
positive exponents
Single precision (32-bit) Range 10-38 to 1039
Can use two words (uses more storage) and
increase exponent (and mantissa) size.
Double precision Range 10-308 to 10308 11-
bit exponent with 1023 bias 52- bit mantissa
26
Real Number RepresentationProblem 2
Not every fraction can be represented exactly in
a given number of bits. Some numbers can not be
represented in any number of bits.
  • There is a hole near zero because the number
    nearest to zero that can be represented is 2-n
    where n is the number of bits in the mantissa.
  • Round-off error is created when bits are stripped
    from the end of a mantissa.

27
Holes in Representation
Assume an 8 bit word with a 3 bit mantissa the
number line below represents all the possible
positive numbers.
Note that numbers near zero can not be
represented and that as the magnitude of numbers
get larger the interval between numbers
(round-off error) gets larger.
28
Round-Off Error
If we represent the perfectly good decimal
fraction 0.1 as a binary fraction we
get 0.00011001100110011001100110011011 (0110
repeats) Suppose we have a computer that stores
11 bits in the mantissa. The binary fraction
(after rounding) becomes 1.100110011012-4
0.100006110
29
Machine Epsilon
A calculable quantity which quantifies maximum
round-off error in a computer which uses certain
length word is called machine epsilon (emach).
emach is the smallest representable real number
that can be added to 1.0 and the result be
different than 1.0 For most 32-bit applications
its value is approximately 2x10-16.
30
Round-Off Error
  • Even though 2 numbers look the same, they might
    be different for a computer
  • Dont compare floating point numbers for
    equality/inequality
  • Compare using lt, lt, gt, gt

31
Character Representation
  • ASCII encoding (American Standard Code for
    Information Interchange)
  • 128 characters defined. This requires 7-bits
  • Unicode extends ASCII to include other characters
  • 8-bit adds and additional 128 characters to
    normal ASCII
  • 16-bit allows representation of most any
    recognizable language most technical symbols.

32
(No Transcript)
33
ASCII Character Representation
Suppose the name Steve Swinnea is to be
represented using ASCII character codes. The
internal representation is
01010011011101000110010101110110
01100101011011100010000001010011
01110111011010010110111001101110
01100101011000010000000000000000
Each character requires 8-bits. The bit patterns
are easy for a computer to understand but is a
bit too much for the human eye.
A more compact representation can be obtained by
converting each group of four bits to hexadecimal.
34
Hexadecimal (Base 16) Representation
35
ASCII Character Representation
Steven Swinnea
01010011011101000110010101110110
01100101011011100010000001010011
01110111011010010110111001101110
01100101011000010000000000000000
e a
e v
n n
S t
e n
w i
S
5374 6576 656E 2053 7769 6E6E 6561
36
Goals of Computer Data Representation
  • Compactness - compact data representation
    requires less storage space and less expensive
    processing and storage devices.
  • Accuracy - the accuracy of representation
    increases with the number of data bits used.

37
Goals of Computer Data Representation
  • Range routine calculations can generate
    quantities that are either too large or too small
    to be stored within finite circuitry.
  • Ease of manipulation - the efficiency of a
    processor depends on its complexity.

38
Goals of Computer Data Representation
  • Standardization - various organizations have
    created standard data encoding methods for
    communication among computer systems and their
    components.

39
Internal (binary) representation is difficult to
read. Hexadecimal is a reasonable way to make
computer memory content more readable.
40
Since they are closely tied to binary numbers
base 16 (hexadecimal) is a good choice for memory
dumps.
Convert to hex
41
Memory Dump
One byte 2 Hex digits 8 bits
Write a Comment
User Comments (0)
About PowerShow.com