Not being an expert mathematician myself, I would just make a function, something like this.
Just used a button and 2 fields for testing.
Maybe there is a more elegant solution.  
 
 
Code: Select all
on mouseUp pMouseButton
   put roundSixteenths(fld "input_Field") into fld "result_Field"
end mouseUp
function roundSixteenths pNumber
   put trunc(pNumber) * 16 into tSixteenths 
   put (pNumber - trunc(pNumber)) / 0.0625 into tRemainder
   add trunc(tRemainder) to tSixteenths
   if tRemainder - trunc(tRemainder) > 0 then add 1 to tSixteenths
   return tSixteenths / 16
end roundSixteenths
Or the shorter, but less readable version.
Code: Select all
function roundSixteenths pNumber
   put (trunc(pNumber) * 16) + trunc((pNumber - trunc(pNumber)) / 0.0625) into tSixteenths 
   if pNumber - (tSixteenths /16) > 0 then add 1 to tSixteenths
   return tSixteenths / 16
end roundSixteenths
P.S. I just tried Craig's solution, I thought of doing this initially, but if you input 4.375 it returns 4.4375 so you would need to change the line
Code: Select all
return round(var / 0.0625 + 0.5) * 0.0625
to something like
Code: Select all
return round(var / 0.0625 + 0.499999999) * 0.0625
It really depends on the amount of numbers behind the decimal point, using the round function like this could result in some errors, I'm sure they would be negligible, but for no errors at all, I think you will need to do the maths.
Paul