in the floating point number system f = [a = 2, k− = −4, k+ = 4, t = 5] the normalized, regularly rounded representation of 0.804 is: in matlab

In the given floating point number system f = [a = 2, k− = −4, k+ = 4, t = 5], the number 0.804 cannot be exactly represented.

To find the normalized, regularly rounded representation, we need to first convert 0.804 to binary. To do this, we can use the following Matlab code:

main.m
num = 0.804;
bin = dec2bin(num)   % Convert to binary
54 chars
3 lines

This gives us the binary representation 0.11001000111101011100001010001111010111000010100011111.

Next, we need to round this to the nearest number that can be represented in the given floating point system. To do this, we need to check the bits beyond the significant bit (the first bit after the radix point) to see if they are greater than or equal to half the value of the next bit. In this case, the bit immediately after the significant bit is 1, and all the bits beyond that are less than 0.5. Therefore, we round up the significant bit to 1.

Next, we need to check if this causes an overflow or underflow in the exponent. The exponent range is given by k- <= e <= k+, where k- = -4 and k+ = 4. The current exponent is 5 (since we moved the radix point to the left by 5 bits), which is outside the allowed range. Therefore, we have an overflow and we need to increase the exponent and shift the bits to the right. The new exponent will be 6, and we need to shift the bits to the right by 1 bit to get the following representation:

main.m
0.110010001111011_2 * 2^6
26 chars
2 lines

Finally, we need to convert this back to decimal. We can do this in Matlab using the following code:

main.m
new_num = bin2dec('110010001111011') / 2^15
44 chars
2 lines

This gives the resultant number 0.80078 as the normalized, regularly rounded representation of 0.804 in the given floating point system.

related categories

gistlibby LogSnag