Professional Documents
Culture Documents
Engineering
Embedded Systems
Information Representation in
Embedded Systems
Lecture 2
Dr F Bensaali
Content:
Numbers
Unsigned integers
Signed integers
Fixed-point
Floating-point
Text
The American Standard Code for Information Interchange (ASCII)
code
10100101
Addition
The two numbers in an addition are addend and the augend.
The result is the sum
Four cases can occur when adding two signed binary numbers:
Both numbers positive
Positive number with magnitude larger than negative number
Negative number with magnitude larger than positive number
Both numbers negative
Addition - examples
Using 8-bit signed numbers:
Both numbers positive
00001001
+ 00000111
+ 7
00010000
16
Discard
the carry
15
+ 11100111
+ -25
11110110
-10
00001010
10
+ 11111010
+ -6
100000100
4
The sum is positive and therefore
in true binary
Discard
the carry
11111011
-5
+ 11111010
+ -6
111110101
-11
The sum is negative and
therefore in 2's complement form
7
120
+
60
180
Sign incorrect
magnitude incorrect
Subtraction
Subtraction is a special case of addition
Subtracting y (the subtrahend) form x (the minuend) is equivalent
to adding y to x
The signed of a positive or negative binary number is changed by
taking its 2s complement
Multiplication
This is similar to multiplication of decimal numbers
Each bit in the multiplier is multiplied by the multiplicand to get
the corresponding partial product
Step 1
Step 2
Determine the sign of the product from the sign of the multiplicand and multiplier
Change any negative number to true form (uncomplemented)
Starting with the list significant multiplier bit, generate the partial products. Shift each
successive partial product one bit to the left
Step 3
Step 4
Step 5
Add each successive partial product to the sum of the previous partial products
If the sign determined in step 1 is negative, take the 2s complement of the product
10
Multiplication (Contd)
Example
01010011
x 01000101
01010011
+ 00000000
001010011
+ 01010011
0110011111
+ 00000000
00110011111
+ 00000000
000110011111
+ 00000000
0000110011111
+ 01010011
01011001011111
+ 00000000
001011001011111
Multiplicand
Multiplier
1st partial product
2nd partial product
sum
3rd partial product
sum
4th partial product
sum
5th partial product
sum
6th partial product
sum
7th partial product
sum
8th partial product
final product
11
Fixed-point representation
There are a number of ways that non-integers (real numbers)
can be represented
Fixed-point and Floating-Point representations are the most
commonly used ways
o Floating-point representation is more accurate than fixed-point
representation
o Fixed point data type is used widely in digital signal processing
(DSP), where performance is sometimes more important than
precision
12
110112 = 2710
if we divide the number 27 by 2,
we know the result should be
13.5
How do we represent it
if we only had integer
representations?
Power
Base
Digits
1
10
1
0
10
3
-1
10
5
Total units:
(1x101)+(3x100)+(5x10-1)
DECIMAL number:
13.510
Bits on the right of binary point carry a weight (power) of 2-1, 2-2,
2-3 and so on
1101.12
Power
Base
Digits
3
2
1
2
2
1
1
2
0
0
2
1
-1
2
1
Total units:
(1x23)+(1x22)+ (0x21)+(1x20)+(1x2-1)
Binary number: 1101.12 = 13.510
15
16
...
Fractional part
(n bits)
...
+2-n
+2-3=0.125
+2-2=0.25
+2-1=0.5
17
Example
0.7510 = ?
0.75 x 2 = 1.5
0.5 x 2 = 1.0 (fractional part =0)
0.7510 = 0.112
19
53.62510 = ?2
20
21
-8.687510 = ?2
22
23
= () .
x31
sign
x30
x23 x22
exponent (8 bits)
= () .
x0
x63 x62
sign
x52 x51
x0
24
10000000
00110000000000000000000
=
e= 10000000=128 10
m=00110000000000000000000= + = .
= () . = () .
= . = .
25
Text
The American Standard Code for Information Interchange (ASCII)
code is a binary code in which 7-bit vectors are used to represent:
Alphabetic characters;
Numeric characters; and
Symbolic characters
26
Text (Contd)
Hexadecimal to ASCII text conversions
27
Text (Contd)
More recent versions of the code include extended ASCII
o It uses the 8th bit in the standard byte to include 128 other
characters
28