In: Computer Science
1. Convert 5.5 to hexadecimal notation using IEEE 754
single precision. Please show your
work and answer must be in hexadecimal notation.
2. (4 points) Convert -7.875 to hexadecimal notation using
IEEE 754 single precision. Please show your
work and answer must be in hexadecimal notation.

1)
5.5
Converting 5.5 to binary
Convert decimal part first, then the fractional part
> First convert 5 to binary
Divide 5 successively by 2 until the quotient is 0
> 5/2 = 2, remainder is 1
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 101
So, 5 of decimal is 101 in binary
> Now, Convert 0.50000000 to binary
> Multiply 0.50000000 with 2. Since 1.00000000 is >= 1. then add 1 to result
> This is equal to 1, so, stop calculating
0.5 of decimal is .1 in binary
so, 5.5 in binary is 00000101.1
5.5 in simple binary => 101.1
so, 5.5 in normal binary is 101.1 => 1.011 * 2^2
single precision:
--------------------
sign bit is 0(+ve)
exponent bits are (127+2=129) => 10000001
Divide 129 successively by 2 until the quotient is 0
> 129/2 = 64, remainder is 1
> 64/2 = 32, remainder is 0
> 32/2 = 16, remainder is 0
> 16/2 = 8, remainder is 0
> 8/2 = 4, remainder is 0
> 4/2 = 2, remainder is 0
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10000001
So, 129 of decimal is 10000001 in binary
frac/significant bits are 01100000000000000000000
so, 5.5 in single-precision format is 0 10000001 01100000000000000000000
Hexadecimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Use this table to convert from binary to hexadecimal
Converting 01000000101100000000000000000000 to hexadecimal
0100 => 4
0000 => 0
1011 => B
0000 => 0
0000 => 0
0000 => 0
0000 => 0
0000 => 0
So, in hexadecimal 01000000101100000000000000000000 is 0x40B00000
in hexadecimal it is 0x40B00000
2)
-7.875
Converting 7.875 to binary
Convert decimal part first, then the fractional part
> First convert 7 to binary
Divide 7 successively by 2 until the quotient is 0
> 7/2 = 3, remainder is 1
> 3/2 = 1, remainder is 1
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 111
So, 7 of decimal is 111 in binary
> Now, Convert 0.87500000 to binary
> Multiply 0.87500000 with 2. Since 1.75000000 is >= 1. then add 1 to result
> Multiply 0.75000000 with 2. Since 1.50000000 is >= 1. then add 1 to result
> Multiply 0.50000000 with 2. Since 1.00000000 is >= 1. then add 1 to result
> This is equal to 1, so, stop calculating
0.875 of decimal is .111 in binary
so, 7.875 in binary is 00000111.111
-7.875 in simple binary => 111.111
so, -7.875 in normal binary is 111.111 => 1.11111 * 2^2
single precision:
--------------------
sign bit is 1(-ve)
exponent bits are (127+2=129) => 10000001
Divide 129 successively by 2 until the quotient is 0
> 129/2 = 64, remainder is 1
> 64/2 = 32, remainder is 0
> 32/2 = 16, remainder is 0
> 16/2 = 8, remainder is 0
> 8/2 = 4, remainder is 0
> 4/2 = 2, remainder is 0
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10000001
So, 129 of decimal is 10000001 in binary
frac/significant bits are 11111000000000000000000
so, -7.875 in single-precision format is 1 10000001 11111000000000000000000
Hexadecimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Use this table to convert from binary to hexadecimal
Converting 11000000111111000000000000000000 to hexadecimal
1100 => C
0000 => 0
1111 => F
1100 => C
0000 => 0
0000 => 0
0000 => 0
0000 => 0
So, in hexadecimal 11000000111111000000000000000000 is 0xC0FC0000
in hexadecimal it is 0xC0FC0000