say i have
length = 146.580377196
when displayed in my current style (feet&inches with 1/16 precision), it should read:
12’2-9/16
i can’t seem to figure out the right way to get that length to show up with my style via python… the most i’ve been able to get so far is to show the decimal version at my absolute tolerance setting
will someone kindly show me the way?
thanks!
nvrmnd
i made a converter
import math import fractions def feet_inches(decimal): """converts decimal inches to feet&inches format: precision @ 1/16th inch """ tol = round(decimal * 16) a = math.modf(tol / 16) feet = int(a[1] // 12) inch = int(a[1] % 12) fract = fractions.Fraction(a[0]) if fract == 0: fract = "" fi= str(feet)+" - "+str(inch)+" "+str(fract) return fi print feet_inches (127.39457)
10 - 7 3/8
i only tested it a little bit so far but it seems to do the trick… let me know if you spot any fail points.
edit- oh… if anybody needs to use this by any chance and you need to change the precision, it should work if you change the two 16 entries (in tol and a) to 8 or 32 or 64 etc…