Last active
August 15, 2017 09:18
-
-
Save erget/90b2f59668d92fb34626f27cfef677df to your computer and use it in GitHub Desktop.
Show value domain given scale and reference value and width of field in bits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Show range and precision of encodable values.""" | |
import argparse | |
parser = argparse.ArgumentParser(description=__doc__) | |
parser.add_argument("scale", help="Scale value", type=int) | |
parser.add_argument("reference", help="Reference value", type=int) | |
parser.add_argument("width", help="Width in bits", type=int) | |
args = parser.parse_args() | |
max_val = (2**args.width - args.reference) * 10**-args.scale | |
print "Minimum value: " + str(args.reference) | |
print "Maximum value: " + str(max_val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment