Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-03-03 18:50:13

This looks most interesting, and there most definitely remains a great need for
a units handling package.

I presume you have looked at W W Brown's SI units proposal

and wonder why you rejected it and how your proposal is different.


PS It seems that time gets into global namespace. I agree it should not be
there but don't know how to fix it. I hit the same problem in my previous
(rudimentary) attempt with units.

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
Mobile mailto:pabristow_at_[hidden]

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Eric Ford
> Sent: Friday, February 28, 2003 8:46 AM
> To: boost_at_[hidden]
> Subject: [boost] (no subject)
> I decided that I needed a workable units library, so I wrote one. It
> allows for weakly typed dimensioned quantities (so a length divided by
> a time is automatically converted to a velocity). It also allows
> users to use strong typeing for quantities of the same dimension which
> shouldn't be confused (so you don't set a mass of apples equal to a
> mass of oranges).
> I attempted to make it pretty general, allowing for all the standard
> SI dimensions, a dimension for money (since that is something lots of
> people care about), and I've left one dimension avaliable for users.
> Fractional powers of dimnensions are allowed. (It also includes a
> compile-time fractions header file that might be useful for other
> purposes.) Power users could setup units using their own classes
> for the internal numeric type or even provide their own systems of units.
> I uploaded the first draft version of it to the vault a
> I've included several demonstration programs to show how it can be used.
> example1.cpp demonstrates the use of simple SI units, including arithmetic
> on such variable and automatic conversion when multiplying or dividing
> dimensioned quantities.
> example2.cpp demonstrates how you could use multiple representations
> (e.g., float and double) in the same program. I've included extremely crude
> numeric type promtion mainly for demonstration purposes.
> example3.cpp demonstrates the use of multiple systems of units in a
> single program (e.g., including both standard/si/mks units and
> "relativistic units where the speed of light is set to unity).
> SIUnits only allows one in a program. Any conversions
> between systems must be made explicitly.
> example4.cpp demonstrates basic use of "qualifiers". These allow
> users to make strongly typed units, so that quantities of the same
> dimension, but different meaning can't be confused. (e.g., a mass
> of apples and a mass of oranges)
> example5.cpp demonstrates how a user can extend this to allow for
> some automatic conversions (e.g., automatically convert apples to
> fruits, but not vice versa, or add apples and oranges and assign
> the result to fruits).
> Known bugs/limitations:
> - In the mks_double and mks_single namespaces, time is non-standard in
> that it is capitalized unlike all the other dimenions. This is due to
> my compiler (g++ 3.0.4 on rh) having conflicts with time (which I
> beleive should be in the std namespace). Help on solving this would
> be appreciated.
> - Many more dimensions could be predefined in the standard system
> (basically SI). However, I'd prefer not to define every possible unit
> (like SIunits), particularlly those that are not frequently used
> (e.g., furlong) and/or those which can be easily constructed by the
> user (e.g., meters per second).
> - Headers for other internal numeric representations (e.g., mks_int
> ???) could be included.
> - Other systems (quantum, natural, planetary, ...) could be included.
> - The system tag classes (e.g., mks_tag, which provides for
> identifying which system of units is being used and labeling the
> dimension of quantities) could be made more intelligent. For example,
> SIUnits allows users to set the default unit that they'd like a
> quantity with a certain dimension to be displayed as. Since one can
> simply divide by whatever unit they want their result in, I don't see
> much point. However, if someone wanted this, they should be able to
> add such features by replacing the sytem tag class class without touching
> the rest.
> Bugfixes, improvements, encouragment, and other feedback would be welcome.
> --------------------------------------
> Protect yourself from spam,
> use
> _______________________________________________
> Unsubscribe & other changes:

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