Boost logo

Boost :

From: Cromwell Enage (sponage_at_[hidden])
Date: 2005-03-24 18:02:40


--- Andy Little wrote: ---
> What is the rationale for the 4 different types
> representing rational fractions?

Presumably you mean fraction, fraction_c, rational,
and rational_c?

The fraction_c struct template is simply a
metafunction that returns a fraction type, and the
rational_c struct template returns a rational type.
(Or was it the other way around?) The fraction struct
template covers a smaller range of numbers than the
rational struct template, but the rational struct
template models the concept of a mixed number, which
consists of a whole number part and a fraction part,
so I figured both the fraction and rational
representations were essential. It certainly made
implementation simpler.

> What is the rationale for making the numerator and
> denominator types in fraction_c?

In an earlier version, the numerator and denominator
were defined by BOOST_STATIC_CONSTANT. Looking
through the Integral Constant Guidelines and the MPL
source code, I read that certain compilers were likely
to complain about the very code I used to have:
BOOST_STATIC_CONSTANT before typedef statements,
fraction_c<long,7,8>::value inside macros, etc. Not
that I have these compilers on hand, but I figured I
wasn't making this sub-library just for myself,
either, so I searched for a better representation. Lo
and behold, Aleksey Gurtovoy created a set of
arithmetic metafunction classes that do the dirty work
for me. I simply built on top of his work.

                              Thanks for your
interest!
                              Cromwell D. Enage

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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