Skip to content

Instantly share code, notes, and snippets.

@atksh
Created June 29, 2021 12:50
Show Gist options
  • Select an option

  • Save atksh/312eddde53e959d4f34d01ce5a4a8970 to your computer and use it in GitHub Desktop.

Select an option

Save atksh/312eddde53e959d4f34d01ce5a4a8970 to your computer and use it in GitHub Desktop.
convert IEEE-111073-16bit-sfloat to float
import numpy as np
def to_float_from_11073_16bit_sfloat(data):
tmp = int.from_bytes(data, "little")
uint16val = np.array([tmp], dtype=np.uint16)
tmp = bin(uint16val[0] & 0xfff)
mantissa = int(tmp, 0)
tmp = np.right_shift(uint16val, 12)
exponent = int(bin(tmp[0]), 0)
ret = round(mantissa * pow(10, exponent), 1)
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment