Boost logo

Boost :

From: González Cuadrado, Miguel (mgcuadrado_at_[hidden])
Date: 2003-07-21 08:17:43


[boost] Static compile-time fractions

I have developed a small library that allows to do compile-time computations using rational numbers; it is heavily template-based. I use as a part of a units library (yet another), in which the dimension is encoded as seven rational numbers, one for the exponent of each of length, time, temperature and so on; each of these rational numbers is a template argument for a magnitude with dimension. (Fractional dimension units are used sometimes, for example for turbo engine analysis and simulation.)

The compile-time fractions library supports unary plus and minus, binary plus and minus, multiplication, division, and integer exponents, and always reduces numerator and denominator, i.e. (4/-6) -> (-2/3), which makes it possible to test for equality. If there is interest in this library, I will try and get it into boost's design criteria. Please let me know.

        Miguel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk