Boost logo

Boost :

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

> // quote from test_units.cpp line 134
> SI<double>::Length l1(7777.0),
> l2(l1);
> l2 /= 3333;
> l2 *= 3333;
> std::cout << std::boolalpha
> << (l1 == l2) << std::endl
> << (l1 != l2) << std::endl
> << (l1 <= l2) << std::endl
> << (l1 < l2) << std::endl
> << (l1 >= l2) << std::endl
> << (l1 > l2) << std::endl
> << std::endl;

I'm guessing that you're making an oblique reference to numeric
precision issues and their interplay with the comparison operators...
The units library is templated on value type, which is not restricted
to POD types, as I demonstrate in test_units.cpp, lines 188-199. There
I use a class called Measurement which does simple error propagation
(just meant as a toy demonstration, not a full-fledged error
propagating type). Because the units library merely delegates
comparisons to the underlying value type, if you implement a FuzzyFloat
class which performs logical comparisons with fuzzy logic and then
write SI<FuzzyFloat>::Length l1,l2 etc..., the result of the code above
will be consistent with those definitions... I think it's important to
understand that my units library performs dimensional analysis for
arbitrary unit systems, with the SI, CGS, etc... systems being provided
for convenience. It doesn't do anything with the value type arithmetic
except delegate, as I believe it should.


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