Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2003-12-15 19:38:31

> | It is not uncommon to have expressions like sin(theta + theta^2). It
> | sure doesn't look clear to me that theta and theta^2 should have
> | different units. They should certainly be allowed to mix.
> |
> This might be what you want, but it may conflict with what dimensional
> analysis/checking system is possible in C++.
> To achieve this in practice, could you reasonably require the user to
> cast to
> some POD?
> sin(static_cast<float>(theta) + static_cast<float>(theta^2) );

There are a couple of options for those who don't feel that degrees and
should be classified as units :

1) continue to use the <cmath> functions and go on your merry way.
2) extract the value from the unit like this :
3) convert the units to dimensionless like this :
std::sin(theta/_radians + (theta/_radians)^2)
4) write your own dimensional analysis/unit library and prohibit the
use of angle tags

I personally feel like this discussion is largely tangential (and am
under the distinct
impression that Mr. Landry couldn't be bothered to give the SI web
site I referenced
his time). Whether or not your personal religion admits degrees,
radians, bunches of
grapes, dozens, or any other random existing or future tag is largely
irrelevant. There
are people for whom it will be helpful in decreasing the error
potential of their code to
be able to use dimensional analysis, and those people are the users I'd
like to target
with this library. If you don't like the fact that radians appear in
the SI unit system, there
is no compulsion to use them nor any consequence to not doing so.


Matthias Schabel, Ph.D.
Utah Center for Advanced Imaging Research
729 Arapeen Drive
Salt Lake City, UT 84108
801-587-9413 (work)
801-585-3592 (fax)
801-706-5760 (cell)
801-484-0811 (home)
mschabel at ucair med utah edu

Boost list run by bdawes at, gregod at, cpdaniel at, john at