units and trunc()

units and trunc() - Сообщения

#1 Опубликовано: 09.09.2010 01:34:40
gregben

gregben

2 сообщений из 4 понравились пользователям.

Группа: 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 Опубликовано: 09.09.2010 02:32:46
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: 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 Опубликовано: 09.09.2010 11:33:26
gregben

gregben

2 сообщений из 4 понравились пользователям.

Группа: User

This worked well. Thank you!
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений