The other
day I was looking to round the value of a parameter. I was actually
calculating distance from the floor to the top of a flange on a conical
tank and the value came with billion digit precision. It's nice to
have it but it doesn't look professional when dimensionsing or
measuring from it.
Couple of
words on rounding parameters and using functions:
Functions
The
following are the supported functions as presented in the Autodesk
Inventor help page.
Syntax

Returns
Unit Type

Expected
Unit Type

cos(expr)

unitless

angle

sin(expr)

unitless

angle

tan(expr)

unitless

angle

acos(expr)

angle

unitless

asin(expr)

angle

unitless

atan(expr)

angle

unitless

cosh(expr)

unitless

angle

tanh(expr)

unitless

angle

acosh(expr)

angle

unitless

asinh(expr)

angle

unitless

sqrt(expr)

unit^1/2

any

sign(expr)

unitless

any
(Return 0 if negative, 1 if positive.)

exp(expr)

unitless

any
(Return exponential power of expression: for example, return 2
for 100, 3 for 1000, and so on.)

floor(expr)

unitless

unitless
(Next lowest whole number.)

ceil(expr)

unitless

unitless
(Next highest whole number.)

round(expr)

unitless

unitless
(Closest whole number.)

abs(expr)

any

any

max(expr1;expr2)

any

any

min(expr1;expr2)

any

any

ln(expr)

unitless

unitless

log(expr)

unitless

unitless

pow(expr1;expr2)

unit^expr2

any
and unitless, respectively

random(expr)

unitless

unitless

isolate(expr;unit;unit)

any

any

The
last one isolate is used to change from one unit to another and this
if usefull if you need to calculate the number of holes (of type
unitles ul) by dividing a linear dimension (of unit mm) by another
linear dimension (of unit mm). The normal result will be of type mm
and you need to convert it to unitless ul like this:
isolate((total_length
/ hole_dist); mm; ul)
Now
I was looking to round the result of an equation to an integer but
the result was surprising.
Round 1497.21 = 1500 ?!?
Ceil 1497.21 = 1500 ?!?
Floor 1497.21 = 1490 ?!?
Round 1497.00 = 1500 ?!?
Ceil 1497.00 = 1500 ?!?
Floor 1497.00 = 1490 ?!?
Round 1497.51 = 1500 ?!?
Ceil 1497.51 = 1500 ?!?
Floor 1497.51 = 1490 ?!?
So in order to get a proper rounding you need to multiply it first by a multiple of 10, then do the operation and divide again by the same 10 multiple.
Round (1497.21 * 10) /10 = 1497
Ceil (1497.21 * 10) / 10 = 1498
Floor (1497.21 * 10) / 10 = 1497
Round (1497.00 * 10) /10 = 1497
Ceil (1497.00 * 10) / 10 = 1498
Floor (1497.00 * 10) / 10 = 1497
Round (1497.51 * 10) /10 = 1498
Ceil (1497.51 * 10) / 10 = 1498
Floor (1497.51 * 10) / 10 = 1497
I am missing something and it's got to do with the unit conversion for sure, but for now this will do.
ADS
No comments:
Post a comment