Skip to content

Instantly share code, notes, and snippets.

@joelkim
Last active December 19, 2023 01:21
Show Gist options
  • Select an option

  • Save joelkim/58a72f5c56cf7fe9a28fb13b20236428 to your computer and use it in GitHub Desktop.

Select an option

Save joelkim/58a72f5c56cf7fe9a28fb13b20236428 to your computer and use it in GitHub Desktop.
def float2bytestr(x: float) -> str:
import struct
return "{0:032b}".format(
int("".join([f"{i:02X}" for i in list(struct.pack("!f", float(x)))]), 16)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment