I am using the rational class (which is actually based on the boost.rational library) as the second parameter of the quantity field. Declaring the quantity presents no problem. However, conversion from one unit to another has more problems because my rational class doesn't support double. It shouldn't support double because I'm trying to make sure conversion factors are all represented as rational numbers. This conversion part is what I am having trouble with. I'm just trying to see if there is an easy way to convert units using rational conversion factors in boost.units without resorting to re-writing some of the units library code. I hope this makes more sense? 

Thanks!

> From: olaf.meeuwissen@avasys.jp
> To: boost-users@lists.boost.org
> Date: Mon, 23 Jan 2012 08:44:10 +0900
> CC: boostusers@googlegroups.com
> Subject: Re: [Boost-users] [units] Question about user-defined value types
>
> W Z <zwt2002@hotmail.com> writes:
>
> > The rational type right now has a numerator and a denominator, both
> > are long type. I would like to support operations with rational
> > numbers only to keep the number representation precise, so no double
> > types should be involved.
> >
> > I first tried to get scaled units working with rational
> > numbers. However, make_scaled_units takes in a scale and then
> > internally returns a double value as a scale. I then wrote my own
> > scale class but it's only partially working (conversion works one way
> > only). It just seems like boost.units has a lot of places internally
> > that use double as scale factors and conversion factors, and I'm
> > looking for a cleaner way to make units library support rational
> > numbers without re-writing a lot of code. Any idea would be greatly
> > appreciated!
>
> I've only just started looking at Boost.Unit, but your comments made me
> wonder if you're specifying the second template parameter to quantity.
> The boost/units/quantity.hpp file has
>
> template<class Unit, class Y = double> class quantity;
>
> I would think that something like
>
> quantity<length, rational> distance;
>
> ought to work as expected.
>
> BTW, you are aware of Boost.Rational, right?
>
> Hope this helps,
> --
> Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION
> FSF Associate Member #1962 Help support software freedom
> http://www.fsf.org/jf?referrer=1962
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users