local a,b
a = 13.4875
The number 0.015625 is exactly 1/64 so this rounds the number to 64ths. If the fraction component is less than 1/128, it is set to zero; if it’s greater than 127/128, it’s set to zero and the mantissa is incremented by one, so an initial 13.993 would become 14.0. In the above case, the value of a becomes 13.484375, where 0.484375 is exactly 31/64.
a = round(a,0.015625)
The mantissa (integer component) is stored in b.
b = int(a)
The fraction component is divided by 0.015625 to calculate the number of 64ths.
a = (a-b)/0.015625
The mantissa is stored in b as a string and this is concatenated with the result of a set of cascading ?(
functions which test for the number of 64ths in the variable, a, being a multiple of 0, 32, 16, 8, 4, 2 or 1 and then display the outcome as a fraction.
b = ?(b=0,"",str(b)+" ") + ?(a=0,"",
?(a mod 32 = 0,str(a/32)+"/2",?(a mod 16 = 0,str(a/16)+"/4",
?(a mod 8 = 0,str(a/8)+"/8",?(a mod 4 = 0,str(a/4)+"/16",
?(a mod 2 = 0,str(a/2)+"/32",str(a)+"/64"))))))