Boost logo

Boost :

From: Dean Foster (foster_at_[hidden])
Date: 2001-09-14 08:48:33


> From: Deane_Yang_at_[hidden]
>
> My gut instinct is that formulas that mix one object measured in
> inches and another measured in centimeters should not occur
> very often even in physics software and should be made as
> explicit as possible.

I too am curious how this would come up. I can think of function that
would have a signature of:

        mass/volumn density(mass m, distance r)

but why would you want two fuctions:

        kg/m^3 density(kg m, m r)
        kg/cm^3 density(kg m, cm r)

or heaven forbid:

        kg/m^3 density(lbs m, yard r)

The fact that C++ wouldn't allow them anyway suggests that it doesn't
make sense.

So, why would "density" want to know what units m or r was measured
in? Why would this function ever have units attached to it?

Now I can see that constants (c, G, h-bar, etc) all would have to be
defined with units. But once inside an actual function, I would hope
they would simply be called c, G or h-bar and not 2.99x10^8 cm/s,
etc. Thus, the units would be user invisable.

So I see the need for having IO from and into various units. But once
inside C++, I'm not sure why you would mix units.

Can someone provide a code snipet that shows why this is important?

later,

dean

P.S. Just checking if anyone was awake: 10^8 should of course be
10^10. :-) The point being, that these constants should never be
listed with units attached to them anywhere except in a file of
constants.


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