You are on page 1of 9

1.

3 Hexadecimal notation

• Sixteen digits to use: 0 - 9, A - F.


• One Hexadecimal digit represents four binary digits

1011 0101 1110 0011


B 5 E 3

• More human readable.

Microcomputer principles and applications


1.4 BCD numbers

• In Binary-Coded Decimal (BCD) representation each decimal


digit is represented by a fixed number of bits (usually four bits).
For example:

1910 = (0001 1001)BCD


• BCD is very common in electronic systems where a numeric
value is to be displayed.

Microcomputer principles and applications


1.5 Fixed point numbers

• An n-bit fixed number can be represented as


l
X k
X
A= dn−i 2n−k−i + dk−j 2−j
i=1 j=1

where
⋄ l is the number of bits of the whole part.
⋄ k is the number of bits of the fractional part.
For example:
l = 10, k = 6 ⇒
00 0000 0010 1000 00 = (0+· · ·+0+1∗21 +0∗20 +1∗2−1 )10 = (2.5)10
00 0000 0101 0100 00 =
(0 + · · · + 0 + 1 ∗ 22 + 0 ∗ 21 + 1 ∗ 20 + 0 ∗ 2−1 + 1 ∗ 2−2 )10 = (5.25)10

Microcomputer principles and applications


1.6 Floating point numbers

IEEE 754 single-precision binary floating-point format


• 1 sign bit.
• 8 exponent bits
• 24 significant precision bits (23 explicitly stored).
The real value is given 32 bit data with a given biased exponent e

A = (−1)sign × 2e−127 × (1.b22 b21 ...b0 )2 × 2e−127


or more precisely
23
!
X
A = (−1)sign × 2e−127 × 1+ b23−i 2−i
i=1

Microcomputer principles and applications


1.6 Floating point numbers

IEEE 754 single-precision binary floating-point format


• 1 sign bit.
• 8 exponent bits
• 24 significant precision bits (23 explicitly stored).

Sign Exponent (8 bits) Fraction (23 bits)

0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

31 30 23 22 0

Sign = 0
Exponent = 2(e−127)
P23= 2 124−127
= 2 −3

Significand = 1 + i=1 b23−i 2−i = 1 + 2−2 = 1.25


⇒ A = 1.25 × 2−3 = 0.15625.

Microcomputer principles and applications


1.7 Logical and arithmetic operations

Logical operations

A B NOT A A OR B A NOR B A AND B A NAND B A XOR B


0 0 1 0 1 0 1 0
0 1 1 1 0 0 1 1
1 0 0 1 0 0 1 1
1 1 0 1 0 1 0 0

• NOT: Logical complement.


• OR, NOR: Logical disjunction.
• AND, NAND: Logical conjunction.
• AND, NAND: Exclusive OR, A OR B, but not both.
• Bitwise: 0 → 1, 1 → 0.

Microcomputer principles and applications


1.7 Logical and arithmetic operations

Integer arithmetic

• Addition
• Subtraction
• Multiplication
• Division
• Shifting

Microcomputer principles and applications


1.7 Logical and arithmetic operations

Floating-point arithmetic operations


Addition and subtraction
• Represent the floating-point numbers with the same exponent.
• Proceed with the usual addition method.

e=5; s=1.234567 (123456.7)


+ e=2; s=1.017654 (101.7654)
e=5; s=1.234567
+ e=5; s=0.001017654 (after shifting)
----------------------
e=5; s=1.235584654

Microcomputer principles and applications


1.7 Logical and arithmetic operations

Floating-point arithmetic operations


Multiplication and division
• Multiplication is accomplished by miltiplying the significands
while the exponents are added.
• Division is accomplished by subtracting the divisor’s exponent
from the dividend’s exponent, and dividing the dividend’s
significand by the divisor’s significand.

e=3; s=4.734612
× e=5; s=5.417242
-----------------------
e=8; s=25.648538980104

Microcomputer principles and applications

You might also like