(f)
| 186 | _HUGE_VAL = 1.79769313486231e+308 # See <limits.h> |
| 187 | |
| 188 | def _read_float(f): # 10 bytes |
| 189 | expon = _read_short(f) # 2 bytes |
| 190 | sign = 1 |
| 191 | if expon < 0: |
| 192 | sign = -1 |
| 193 | expon = expon + 0x8000 |
| 194 | himant = _read_ulong(f) # 4 bytes |
| 195 | lomant = _read_ulong(f) # 4 bytes |
| 196 | if expon == himant == lomant == 0: |
| 197 | f = 0.0 |
| 198 | elif expon == 0x7FFF: |
| 199 | f = _HUGE_VAL |
| 200 | else: |
| 201 | expon = expon - 16383 |
| 202 | f = (himant * 0x100000000 + lomant) * pow(2.0, expon - 63) |
| 203 | return sign * f |
| 204 | |
| 205 | def _write_short(f, x): |
| 206 | f.write(struct.pack('>h', x)) |
no test coverage detected