The module is useful when you are trying to convert the data into binary formats. However, recently I came across a file format specification that I used to see through the Python documentation, but nothing could be found in it that could change it from and. What would be the best way to convert this data to Python Floats?
You can do this roughly like you want it in C. - that is, I suppose That is, almost like this ...:
def tofloat (b16): sign = -1 if B16 & amp; 0x8000 Other +1 Expo = (B16 and 0x7C00) & gt; & Gt; 10 exacts = B16 & amp; 0x03FF Expo == 0: Return Sign * (2.0 ** -24) * Exact LIF Expo == 0x1F: Return Sign * Float ('INF') Exact = 0x0400 Return Sign * (2.0 ** (Expo -25)) * Exact
Comments
Post a Comment