Professional Documents
Culture Documents
Counting Decimal
0
• Integer 1 • Base 10
2 • Digits 0..9 (=10-1)
– Decimal, Binary, Hexadecimal, General Radix 3
4 • Keep incrementing rightmost digit
– Unsigned vs. Signed 5
until highest digit is reached, then
6
• Real 7 apply same mechanism to
8
9 increment digit to the left und
– Fixed Point 10 reset current digit to 0.
11
– Floating Point …
19
20
..
99
100
Result: 1011012
Bräunl 2014 9 Bräunl 2014 10
Result: 2D16
• Calculate back:
Result = + 2128-127 * 1. 0000..2
• Def.: Number10 = (-1)sign * 2(exponent-127) * 1.fraction2 = 2 * 12
= 210
• Example = + 2-3 * 1.0100..2 = 0.001012 • Exponent is simply a shifting of the "decimal point"
= 0.1562510
Bräunl 2014 Source: Wikipedia 27 Bräunl 2014 28
Floating Point Floating Point Examples
• Def.: Number10 = (-1)sign * 2(exponent-127) * 1.fraction2 • Def.: Number10 = (-1)sign * 2(exponent-127) * 1.fraction2
• Example: • Examples:
1 01111110 10000000000000000000000 2.0010 ! 0 10000000 00000000000000000000000
1.0010 ! 0 01111111 00000000000000000000000
• Calculate back: 0.7510 ! 0 01111110 10000000000000000000000
Result = - 2126-127 * 1. 1000..2 0.5010 ! 0 01111110 00000000000000000000000
= - 2-1 * 1.12 -0.5010 ! 1 01111110 00000000000000000000000
= - 0.112 -0.7510 ! 1 01111110 10000000000000000000000
= - 0.7510 0.0010 ! 0 00000000 00000000000000000000000
Special Cases
Exponent = 0
• Fraction = 0 ! result = 0
• Fraction ≠ 0 ! result = (-1)sign * 2(-126) * 0.fraction2
"denormal number"
Exponent = 1..254
• Regular case ! result = (-1)sign * 2(exp-127) * 1.fraction2
Exponent = 255
• Fraction = 0 ! result is ± infinity
• Fraction ≠ 0 ! result is NaN ("not a number")
Bräunl 2014
after invalid operation, e.g. /0 31