GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 9(a)

Encode a value in a custom hexadecimal float

Computer Organization & Architecture · Data Representation & Arithmetic · Full GATE CSE 2002 paper

GATE 2002, Q9(a) Descriptive
Report issue

Data Representation & Arithmetic

Question 9(a), GATE 2002: A 32-bit floating-point format has fields, from most to least significant: sign (1 bit), fraction (24 bits), exponent (7 bits). Sign 0 means positive and 1 negative. The binary point precedes the fraction bits. The exponent is stored in excess-64 representation, and the exponentiation base is 16. Represent decimal −7.5 as a normalized number in this format. Derive each field and give the complete representation in hexadecimal.
Question 9(a), GATE 2002: A 32-bit floating-point format has fields, from most to least significant: sign (1 bit), fraction (24 bits), exponent (7 bits). Sign 0 means positive and 1 negative. The binary point precedes the fraction bits. The exponent is stored in excess-64 representation, and the exponentiation base is 16. Represent decimal −7.5 as a normalized number in this format. Derive each field and give the complete representation in hexadecimal.
Tap to enlarge
Shared context

The custom 32-bit format stores sign, 24-bit fraction, then 7-bit excess-64 exponent, in that order. Its numeric value is (−1)^s(F/2^24)16^(E−64); no reserved exponent encodings are specified.

Answer & solution

Answer: Sign 1; fraction 0x780000; biased exponent 65; word 0xBC000041 (no official key was published)

1. Write the numeric interpretation of this particular format. For sign bit s, unsigned 24-bit fraction integer F, and unsigned stored exponent E, the value is (−1)s × (F/224) × 16E−64. The storage order is sign, fraction, exponent, unlike IEEE 754.

2. Normalize the magnitude in radix 16. Since 7.5/16 = 0.46875 and 0.46875 = 7/16 + 8/256, we have 7.5 = 0.78₁₆ × 16¹. The leading hexadecimal fraction digit 7 is nonzero, so this is normalized. Leading zeros within that hexadecimal digit’s four binary bits are allowed in radix-16 normalization.

3. Fill each field. The value is negative, so s=1. The six-hex-digit fraction is 780000, giving F=0x780000 and fraction bits 0111 1000 0000 0000 0000 0000. The actual exponent is 1; applying excess-64 gives E=65, whose seven-bit form is 1000001.

4. Concatenate the fields without moving the exponent to the front:

1 | 011110000000000000000000 | 1000001
= 1011 1100 0000 0000 0000 0000 0100 0001
= 0xBC000041

Equivalently, the word is (1 << 31) | (0x780000 << 7) | 65. The fraction is shifted by seven because the exponent occupies the low seven bits.

5. Decode the candidate to verify it: −(0x780000/224) × 1665−64 = −0.46875 × 16 = −7.5 exactly. No rounding is needed because the fraction has a finite binary and hexadecimal representation.

Original paper, page 7