In: Computer Science
Using IEEE 754 single precision floating point, write the hexadecimal
representation for each of the following:
a. Zero
b. -2.0 (base 10)
c. 256. 0078125 (base 10)
d. Negative infinity

a. Zero
0 is stored as all 0's
Answer: 00000000
b. -2.0
-2.0
Converting 2.0 to binary
Convert decimal part first, then the fractional part
> First convert 2 to binary
Divide 2 successively by 2 until the quotient is 0
> 2/2 = 1, remainder is 0
> 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10
So, 2 of decimal is 10 in binary
> Now, Convert 0.00000000 to binary
> Multiply 0.00000000 with 2. Since 0.00000000 is < 1. then add 0 to result
> This is equal to 1, so, stop calculating
0.0 of decimal is .0 in binary
so, 2.0 in binary is 00000010.0
-2.0 in simple binary => 10.0
so, -2.0 in normal binary is 10.0 => 1. * 2^1
single precision:
--------------------
sign bit is 1(-ve)
exponent bits are (127+1=128) => 10000000
Divide 128 successively by 2 until the quotient is 0
> 128/2 = 64, remainder is 0
> 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 10000000
So, 128 of decimal is 10000000 in binary
frac/significant bits are 00000000000000000000000
so, -2.0 in single-precision format is 1 10000000 00000000000000000000000
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 11000000000000000000000000000000 to hexadecimal
1100 => C
0000 => 0
0000 => 0
0000 => 0
0000 => 0
0000 => 0
0000 => 0
0000 => 0
So, in hexadecimal 11000000000000000000000000000000 is 0xC0000000
in hexadecimal it is 0xC0000000
Answer: C0000000
c.
256.0078125
Converting 256.0078125 to binary
Convert decimal part first, then the fractional part
> First convert 256 to binary
Divide 256 successively by 2 until the quotient is 0
> 256/2 = 128, remainder is 0
> 128/2 = 64, remainder is 0
> 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 100000000
So, 256 of decimal is 100000000 in binary
> Now, Convert 0.00781250 to binary
> Multiply 0.00781250 with 2. Since 0.01562500 is < 1. then add 0 to result
> Multiply 0.01562500 with 2. Since 0.03125000 is < 1. then add 0 to result
> Multiply 0.03125000 with 2. Since 0.06250000 is < 1. then add 0 to result
> Multiply 0.06250000 with 2. Since 0.12500000 is < 1. then add 0 to result
> Multiply 0.12500000 with 2. Since 0.25000000 is < 1. then add 0 to result
> Multiply 0.25000000 with 2. Since 0.50000000 is < 1. then add 0 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.0078125 of decimal is .0000001 in binary
so, 256.0078125 in binary is 10000000.0000001
256.0078125 in simple binary => 100000000.0000001
so, 256.0078125 in normal binary is 100000000.0000001 => 1.000000000000001 * 2^8
single precision:
--------------------
sign bit is 0(+ve)
exponent bits are (127+8=135) => 10000111
Divide 135 successively by 2 until the quotient is 0
> 135/2 = 67, remainder is 1
> 67/2 = 33, remainder is 1
> 33/2 = 16, remainder is 1
> 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 10000111
So, 135 of decimal is 10000111 in binary
frac/significant bits are 00000000000000100000000
so, 256.0078125 in single-precision format is 0 10000111 00000000000000100000000
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 01000011100000000000000100000000 to hexadecimal
0100 => 4
0011 => 3
1000 => 8
0000 => 0
0000 => 0
0001 => 1
0000 => 0
0000 => 0
So, in hexadecimal 01000011100000000000000100000000 is 0x43800100
in hexadecimal it is 0x43800100
Answer: 43800100
d)
Negative infinity
sign bit = 1
exponent bits = 11111111
fractional bits = 00000000000000000000000
let's convert 1 11111111 00000000000000000000000 to hexadecimal
Converting 11111111100000000000000000000000 to hexadecimal
1111 => F
1111 => F
1000 => 8
0000 => 0
0000 => 0
0000 => 0
0000 => 0
0000 => 0
So, in hexadecimal 11111111100000000000000000000000 is 0xFF800000
Answer: FF800000