Skip to content
Advertisement

Tag: half-precision-float

Convert 16 bit hex value to FP16 in Python?

I’m trying to write a basic FP16 based calculator in python to help me debug some hardware. Can’t seem to find how to convert 16b hex values unto floating point values I can use in my code to do the math. I see lots of online references to numpy but I think the float16 constructor expects a string like float16(“1.2345”).

Why is it dangerous to convert integers to float16?

I have run recently into a surprising and annoying bug in which I converted an integer into a float16 and the value changed: This is likely not a bug, because it happens also for PyTorch. I guess it is related to half-float representation, but I couldn’t figure out why 2049 is the first integer that is badly casted. The question

Advertisement