units and trunc()

units and trunc() - Messages

#1 Posted: 9/9/2010 1:34:40 AM
gregben

gregben

2 likes in 4 posts.

Group: User

I want to do the following:

length := 16 in

diameter := trunc(((length + 2 in)/pi)in)

diameter = 7.0000 in

I need to be able to set the result of a parenthesis-enclosed
expression
to inch units, then apply the trunc() function to
it, retaining the units as inches. At the moment, it
seems as though it is only possible to apply the trunc()
function to the results of computation in parenthesis
using SI units, so the result becomes 0 because the
value of (length + 2 in)/pi is 0.1779 m.

The workaround seems to be to not use units at all,
but that is not nearly as nice.
#2 Posted: 9/9/2010 2:32:46 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello,

What about this

The argument inside "trunc" divide by the desired unit (in - in this case).
Then, the entire expression multiply by the desired unit (in - in this case)

In general, when you do not want SI units - divide the expression by the desired unit.
Then you will get the dimensionless number with the value in the desired unit.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 9/9/2010 11:33:26 AM
gregben

gregben

2 likes in 4 posts.

Group: User

This worked well. Thank you!
  • New Posts New Posts
  • No New Posts No New Posts