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!

Thanks,
Wenting


Date: Sat, 21 Jan 2012 19:45:35 -0800
From: alfredo.correa@gmail.com
To: boostusers@googlegroups.com
CC: boost-users@lists.boost.org
Subject: Re: [Boost-users] [units] Question about user-defined value types



On Friday, January 20, 2012 8:06:46 AM UTC-8, W Z wrote:
Hi,

I am using boost units library for a project in which I need to define quantities using rational numbers. I have a rational number class but am having trouble integrating it with units library. There seems to be a lot of places where the units library implementation assumes that the conversion values are expressed as double type. Is there a good way to get around this to make units library support rational numbers?

Can you post a particular example? Does you rational type model a double type? what operation is that boost.units need and your class doesn't have?

Thanks,
Alfredo


_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users