Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2004-03-13 23:31:10


Matt Calabrese writes:
> A couple of days ago I started work on a library where I need a way to
> represent rational numbers and fixed point precision numbers at
> compile time, so I started creating a compile-time rational number type
> following the style of integral_c in boost::mpl. After completing most
> operations, I notices that in the mpl/math directory there were already
> the beginnings of rational_c and fixed_c types, however, they are far
> from complete (in rational_c there are just two static constants for
> numerator and denominator and a self typedef, with no specialized
> operations). Are these types still in development or are they
> abandoned?

They are waiting for somebody to pick them up. To some extent, that
already happened with rational numbers. There are a couple of more or
less complete implementations laying around:

 * http://tinyurl.com/2qrpq, 'rational_c' implementation by Hugo Duncan;
 * http://tinyurl.com/39mjl, "static_rational.hpp" by Matthias Schabel
   (it's a part of YANL, his dimensional analysis library).

The main reason one of them is not in the library yet is that their
notation for arithmetic operations leaves something to be desired --
you have to write something like

    rational_plus<r1,r2>

instead of

    mpl::plus<r1,r2>

Besides this issue, AFAIK these are already usable. Of course, if you
would like to improve them/contribute more optimal/clean/better in any
other regard implementation, please do.

As for 'fixed_c', I am not aware of any publicly available
implementation. Again, contributions are more than welcome!

> I'd like to continue my project using
> mpl::rational_c and mpl::fixed_c as I need to make them work with the
> mpl integral constants anyways.
>
> So is development on these templates halted, meaning I should just go
> ahead and finish my types, or are the types coming soon enough so I
> just should just hold off and wait for the cavalry to arrive?

No, please go ahead! Cavalry have enough on their plates already (among
other things, a new version of the library is upcoming, with plenty of
new exciting and useful stuff like associative sequences), so progress
on these two is totally in your hands.

--
Aleksey Gurtovoy
MetaCommunications Engineering

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net