W13 Arithmetic Logic Unit Binary Integer Representation Binary Integer Arithmetic - PPT PDF
W13 Arithmetic Logic Unit Binary Integer Representation Binary Integer Arithmetic - PPT PDF
OBJECTIVES
ARITHMETIC OPERATIONS
• ADD
• ADD WITH CARRY
• SUBTRACT
• SUBTRACT WITH BORROW
• TWO’S COMPLEMENT
• INCREMENT
• DECREMENT
• PASS THROUGH
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION
MULTIPLE-PRECISION ARITHMETIC
• In integer arithmetic computations, multiple-precision
arithmetic is an algorithm that operates on integers which are
larger than the ALU word size. To do this, the algorithm treats
each operand as an ordered collection of ALU-size fragments,
arranged from most-significant (MS) to least-significant (LS) or
vice versa.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION
COMPLEX OPERATIONS
• CALCULATION IN A SINGLE CLOCK
• CALCULATION PIPELINE
• ITERATIVE CALCULATION
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION
To multiply a number by 2 you can simply shift it to the left by one digit,
and fill in the rightmost digit with a 0. To divide a number by 2, simply shift
the number to the right by one digit.
To see how many digits a number needs, you can simply take the
logarithm (base 2) of the number, and add 1 to it. The integer part of the
result is the number of digits. For instance,
log2(86) + 1 = 7.426.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
ADDITION
• ADDING UNSIGNED NUMBERS
• ADDING SIGNED NUMBERS
• ADDING FRACTIONS
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
MULTIPLICATION
• MULTIPLYING UNSIGNED NUMBERS
• MULTIPLYING SIGNED NUMBERS
• MULTIPLYING FRACTIONS
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
0
1 110 1101 (carry)
(carry) (carry) (carry)
1101
06 0110 13
+07 +0111 +0101
+05
13 1101 10010
18
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
ADDING FRACTIONS
1010 1101
x0110 x1110
10 0000 13 0000
x6 1010 x14 1101
60 1010 182 1101
+0000 +1101
0111100 10110110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
There are many methods to multiply 2's complement numbers. The easiest is to simply
find the magnitude of the two multiplicands, multiply these together, and then use the
original sign bits to determine the sign of the result. If the multiplicands had the same
sign, the result must be positive, if the they had different signs, the result is negative.
Multiplication by zero is a special case (the result is always zero, with no sign bit).
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
MULTIPLYING FRACTIONS
Fractional
Decimal
Binary
1100
x0100
-0.5
0000
x0.5
0000
-0.25
+111100
11110000
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
1 bit for the sign, 8 bits for the exponent, and 23 bits for the mantissa. Also
IEEE Short Real: 32 bits
called single precision.
1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa. Also called double
IEEE Long Real: 64 bits
precision.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
0.000000119209289550
0.00000000000000000000001 1/8388608
78125
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
Adjusted
Exponent (E) Binary Representation
(E + 127)
5 +162 10100010
0 +127 01111111
-10 +117 01110101
128 +255 11111111
-1 +126 01111110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
1101.101 1.101101 3
.00101 1.01 -3
1.0001 1.0001 0
10000011.0 1.0000011 7
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION
REFERENCES
https://en.wikipedia.org/wiki/Arithmetic_logic_unit
https://www.webopedia.com/TERM/A/ALU.html
https://www.lindo.com/doc/online_help/lingo15_0/binary_integer_variables.htm
https://en.wikipedia.org/wiki/Binary_integer_decimal
https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html#posint
https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/BinaryMath.html
http://cstl-
csm.semo.edu/xzhang/Class%20Folder/CS280/Workbook_HTML/FLOATING_tut.htm