Boost logo

Boost :

From: Gerhard Wesp (gwesp_at_[hidden])
Date: 2006-06-08 13:04:42


On Wed, Jun 07, 2006 at 10:04:20PM +0100, Reece Dunn wrote:
> working in one unit (SI meters) when they should be working in another
> (e.g. miles). For example, it would be easy to write:
>
> std::cout << "You need " << flour << " pounds of flour\n";

No. Because I would either not define operator<< for a dimensional
quantity OR have it output the unit together with the value. Then it
should be obvious as soon as you see your program's output for the first
time:

  You need 0.815 lbs pounds of flour

> so, which value is correct? The one in Joules (sp?) or the one in

Well, both are probably correct. :) Now I'm not a theoretical
physicist, but I'm pretty sure that even there all but the most trivial
calculations become cleaner once you use SI units. Seems as if I'd want
to mildly encourage even those folks to use SI.

As to your rounding error concerns, I can reassure you, multiplication
and division is very well-behaved in floating point.

> (3) it will have greater runtime penalties, especially if used in a loop;
I fail to see this.

> (4) can have inacuracies when dealing with large or small physical
> constant-based values;
Why/how? In what way different from non-SI?

> (5) is bad if those constants are changing!
Well... If the Lord decides to change the gravitational constant, I
guess we're toast anyway.

> (6) can penalize you if intervals come into play.
I fail to see this, too.

Regards
-Gerhard

-- 
Gerhard Wesp
ZRH office voice: +41 (0)44 668 1878
ZRH office fax: +41 (0)44 200 1818
For the rest I claim that raw pointers must be abolished.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk