← Back to context

Comment by vlmutolo

4 years ago

The "default" formula as presented in the article seems… strange. Is this really how it's normally taught?

    (-1)^S * 1.M * 2^(E - 127)

This seems unnecessarily confusing. And 1.M isn't notation I've seen before. If we expand 1.M into 1 + M : 0 < M < 1, then we pretty quickly arrive at the author's construction of "windows" and "offsets".

    (-1)^S * (1 + M) * 2^(E - 127)
    (-1)^S * 2^log_2(1 + M) * 2^(E - 127)
    
    let F := log_2(1 + M)
    0 < F < 1
    
    Note: [0 < M < 1] implies [1 < M + 1 < 2] implies [0 < log_2(1+M) < 1]

    (-1)^S * 2^(E - 127 + F)

Since we know F is between 0 and 1, we can see that F controls where the number lands between 2^(E - 127) and 2^(E - 127 + 1) (ignoring the sign). It's the "offset".