Chapter 05
Chapter 05
Data representation
CHAPTER 05
2
Contents
Number system
Decimal Base 10. Digits used: 0 to 9
Binary Base 2. Digits used: 0,1
Octal Base 7. Digits used: 0 to 7
Hexa Base 16. Digits used: 0 to 9, Letters used A to F
4
Decimal system
2910= 111012
7
Binary fractions
1’s Complement
2’s Complement
Two’s complement
11
0000
1111 0001
-1 0
1 0010
1110 15
-2 2
14
1101 -3 0011
13 3
move the sign bit to the new leftmost position and fill in with copies
of the sign bit. For positive numbers, fill in with zeros, and for
negative numbers, fill in with ones.
Integer
representation
26
Integer types
http://tinyurl.com/y6ymre56
27
Two complement
http://tinyurl.com/y6ymre56
28
Signed & Unsigned Addition
http://tinyurl.com/y6ymre56
29
String representation
“Hello”
http://tinyurl.com/y6ymre56
“19653”
t 2t-1 -1
3 23-1 -1 = 3
8 28-1 -1 = 127
11 211-1 -1 = 1023
33
3. Normalize the number. Move the binary point so that it is one bit from
the left. Adjust the exponent of two so that the value does not
change, (e.g. 11.01 x 20 → 1.01 x 21 )
4. Place the mantissa into the mantissa field of the number. Omit the
leading one, and fill with zeros on the right,
5. Add the bias to the exponent of two, and place it in the exponent
field,
Examples
Convert 2.625 to 8-bit binary floating-point
3. Mantissa: 0101
5. Sign bit is 0
Examples
Convert -4.75 to 8-bit binary floating-point
3. Mantissa: 0011
5. Sign bit is 1
Examples
Convert -1313.3125 to IEEE 32-bit binary floating-point
3. Mantissa: 01001000010101000000000
5. Sign bit is 1
Examples
Convert e7 binary floating-point (8 bits) to decimal
2. Mantissa: 1.0111
Result: -11.5
38
Heap
BSS – uninitialized data
Data – initialized data
Low memory Text (code)