How to convert Decimal Feet to Fractional Feet and Inches

Here’s a new script that converts decimal feet to a fraction:

The precision input and a few other shortcuts allow the script to run quickly.
0" and dash symbols are controllable as well.

The design script is below:

//Convert Decimal Feet to Imperial Fraction
feet = Math.Floor(feetDec);
inch = Math.Floor(inchDec);
feetDec = Math.Round(numberprec12,0)/(prec12);
inchDec = Math.Round((feetDec-feet)12,8);
fracDec = inchDec-inch;
depthBool = prec==[1,2,4,8,16,32,64,128,256];
index = List.IndexOf(depthBool, true);
power = Math.Pow(2, (0…#index+1…1));
root = List.Transpose((fracDec
n = List.MinimumItem(Math.Round(root)==root? root: root+10000);
ds = β€œ/”+List.Reverse(power)+"";
dInd = List.FirstIndexOf(root@L2<1>, n@L1<1>);
d = List.GetItemAtIndex(ds, dInd);
fracStr = String.StartsWith(n+d, β€œ0”, false)? β€œβ€: " β€œ+n+d;
frac = String.Replace(fracStr, β€œ.000000”, β€œβ€);
end0 = feet+”’"+"-"+inch+frac+""";
endD = String.Replace(end0, β€œ-0"”, show0? β€œ-0"”: β€œβ€);
endFT = String.Replace(endD, β€œ-”, dash);
endIN = (feet


Converting decimal feet to fractional feet and inches


This is great. There are also unit conversion and formatting nodes in package:




The node that I used to use from Springs was my go to for this kind of task. But when I ran the node on a list of about 2,000 items (like a wall schedule) it would take about a minute to finish. So when I had built a code block that could do the same list in just over a second, I thought I had the cat in the bag. On the other hand, your nodes do it instantly. Way more options too!

Precision is an easy adjustment, but Is there a better option for inches?

You can get decimal/fractional inches by defining what formatting you want for your units: