
Re: Equations
John Burrill Apr 19, 2013 6:02 PM (in response to David Spencer)David, you can use an IF statement with the INT operator to round numbers.
For example where D`1 is an equationdriven dimension and D2 is an input value
=if("D2@Sketch10"int("D2@Sketch10")>0.5,int("D2@Sketch10")+1,int("D2@Sketch10"))
will round the dimension to the nearest whole number
If you want to introduce significant digits, just multiply the input value by 10^x power where x is the number of significant digits.
Sof for example, if in the above case I wanted to round the result to two significant digits, I'd enter the value as
=if(100*"D2@Sketch10"int(100*"D2@Sketch10")>0.5,int((100*"D2@Sketch10")+1)/100,int(100*"D2@Sketch10")/100)
For the purposes of making the equation easier to edit, I probably would split out the pieces into a couple of seperate equations
For example
Global variable: Sig_digits; Value: 2
global variable:primer; equation: =10 ^ sig_digits
and then rewrite the equation so that all I have to change is the sig_digits value to adjust the precision of the equations.
Try it out.
John

Re: Equations
Jason Capriotti Apr 22, 2013 7:44 AM (in response to David Spencer)In addition to John's suggestion, you can use a "Round" operation.
round ("a")
a = 34.485
b = round ("a") ' = 34 (Rounds to the nearest whole number)
c = round ("a",2) ' = 34.48 (Rounds to two decimeal places)
d = iif ( round ( "A" ) < "A" , round ( "A" ) + 1 , round ( "A" ) ) 'This would always round up to the nearest whole number.

Re: Equations
Patrick O'Hern Apr 22, 2013 8:46 AM (in response to Jason Capriotti)Here is a great way to round values off to a fractional amount:
=ROUND(D1@Sketch1 * 16,0)/16
This will round your original value to the nearest 1/16". If you want the nearest 1/2", just change the 16's to 2's, or whatever fractinal value you need.


Re: Equations
David Spencer Apr 22, 2013 9:53 AM (in response to David Spencer)Thanks for the help guys. Works like a charm.