sign (1 bit) | exp (# of bits specified in argv[2]) |
frac (# of bits specified in argv[1]) |
Given the input "a8", the program should parse the hex digits into corresponding bit fields. Thus, separating out "a8" gives you 0 1010 1000 for the 3 fields. (Note that we 0-pad the most-significant bits as needed). From this, the exp field is 10 (in decimal) and the frac field is 1⁄2. With a Bias of 7, the resultingvalue M*2E will be M = 1+1⁄2 = 3⁄2 , E = 10 - 7 = 3. Thus, the output will be 12.0.
sign (1 bit) exp (4 bits)
frac (4 bits)