t = a
dp = 0 ### for 0 decimal places
t = (t10**dp).round10**-dp
What i want is the result form a =b/o, is roundup or down to a whole number. So if the result is, for example 5.43 is 5 and 6.79 is 7. But the code i found and used doesn’t seem to work.
Unless you need to support versions of SketchUp prior to SU 2014, you can just use the revised version of Float#round introduced in Ruby 1.9. It takes an argument specifying the number of decimal places to retain:
In calculations you don’t normally need to worry.
Only if you are showing the result as a float in a UI.inputbox ?
If you are formatting as a text string you can use sprintf( )
Where you can do many clever things - e.g. always force 3 dps even when all 0 etc…
There are many examples here…
Also remember that dividing integers can give different results from floats
Also, if you are dealing with model units then make sure to convert to Length and then rely on Length.to_s to convert the unit into the formatting of the current model.