Skip to content

Commit

Permalink
V1.19.01
Browse files Browse the repository at this point in the history
  • Loading branch information
jgyates committed Feb 2, 2024
1 parent 5754a39 commit a778c93
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions genmonlib/custom_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,11 +1767,12 @@ def ProcessBitModifiers(self, entry, value, ReturnFloat = False):
if "shiftleft" in entry.keys():
value = value << int(entry["shiftleft"])
if "ieee754" in entry.keys() and ReturnFloat:
if entry["ieee754"].lower() == "half":
# Use this for testing: https://www.h-schmidt.net/FloatConverter/IEEE754.html
if entry["ieee754"].lower() == "half": # 16 bits
value = float(struct.unpack('f', struct.pack('H', int(value)))[0])
elif entry["ieee754"].lower() == "single":
elif entry["ieee754"].lower() == "single": # 32 bits
value = float(struct.unpack('f', struct.pack('I', int(value)))[0])
elif entry["ieee754"].lower() == "double":
elif entry["ieee754"].lower() == "double": # 64 bits
value = float(struct.unpack('f', struct.pack('Q', int(value)))[0])
else:
self.LogError("Error converting ieee754 floating point: invalid ieee754 type: " + str(entry))
Expand Down

0 comments on commit a778c93

Please sign in to comment.