
Re: Equation to round to nearest fraction
Kevin Chandler Mar 8, 2016 12:33 PM (in response to Anton Miller)Hello,
I've attached a part with the equations in the Manage Equation dialog, so I won't overelaborate here, but:
 Get the integer length and save
 Subtract the remainder and save
 Compute the number of fractions in the remainder and add one.
 Multiple the number of fractions by the fraction and add this to the integer length.
See the attached. I hope it addresses your post.
Cheers,
Kevin

Part1.zip 41.5 KB

Re: Equation to round to nearest fraction
Anton Miller Mar 8, 2016 12:53 PM (in response to Kevin Chandler)wow, so simple! thank you!

Re: Equation to round to nearest fraction
Brian Bump Mar 8, 2016 1:13 PM (in response to Kevin Chandler)Very nice Kevin Chandler!

Re: Equation to round to nearest fraction
Martin MacDonald Mar 8, 2016 1:00 PM (in response to Anton Miller)
Re: Equation to round to nearest fraction
Anton Miller Mar 8, 2016 1:12 PM (in response to Martin MacDonald)good observation! maybe for my uses the rounding up isn't that big of a deal, so I could avoid the added 1/16 for whole numbers by getting rid of the +1 on the (number of fractions) variable. hmmm. wonder if there is a magic number like .7 or something that would fix this for 90% of the situations.

Re: Equation to round to nearest fraction
Anton Miller Mar 8, 2016 1:20 PM (in response to Anton Miller)
Re: Equation to round to nearest fraction
Martin MacDonald Mar 8, 2016 1:27 PM (in response to Anton Miller)
Re: Equation to round to nearest fraction
Anton Miller Mar 8, 2016 1:28 PM (in response to Martin MacDonald)oh nice!
(could get long) I wonder if you could put all 1/16" increments in that if statement?

Re: Equation to round to nearest fraction
Martin MacDonald Mar 8, 2016 2:02 PM (in response to Anton Miller)A very long nested If sstatement would do the trick (obviosuly I have only done it to 8th so it fits on the page !!!!)
= IIF ( "RemainderLength" = 0 , "RemainderLength" , IIF ( "RemainderLength" = 0.125 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.25 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.375 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.5 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.625 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.75 , ( "RemainderLength" * "Fraction" ) , IIF ( "RemainderLength" = 0.875 , ( "RemainderLength" * "Fraction" ) , int ( "RemainderLength" * "Fraction" ) + 1 ) ) ) ) ) ) ) )
I'm sure some programming boffin would be able to get it better but this works  so you can now input whole numbers and 1/16th values and it will give the correct value everytime





Re: Equation to round to nearest fraction
Kevin Chandler Mar 8, 2016 1:48 PM (in response to Martin MacDonald)Hello,
Excellent catch!
Attached is the part that checks for and adjusts to zero.
I think it addresses this shortcoming.
Cheers,
Kevin

Part1zerocheck.zip 41.6 KB

