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

In MATLAB, the normalized, regularly rounded representation of 0.654 in the floating-point number system f=[a=2,k−=−6,k+=6,t=5] can be obtained using the round and log2 functions as follows:

main.m
x = 0.654;
k = log2((1+x)/2) + 6; % compute the exponent k
b = round(x * 2^(t+k-6)); % compute the significand b
f_rep = [0, k, b]; % construct the normalized, regularly rounded representation
193 chars
5 lines

The resulting f_rep will be [0, 6, 101101], since the binary representation of 0.654 is 0.10101010101010101010..., which rounds up to 0.101101 when normalized and rounded to 5 bits. Thus, the IEEE-754 representation of 0.654 in the given floating-point format would be 0 0110 1011010000.

gistlibby LogSnag