Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-10-24 10:32:49

>>>> "David Abrahams" wrote
>>>>> "Andy Little" writes:
>>>>> I don't see what the presence of numerator and denominator has to do
>>>>> with normalization.
>>>> They should be typedefs for the input parameters?
> Hmm, is that meant to be a question?

As it stands in both my and Cromwells version the numerator and denominator are
those of the (so-called) normalized version. This was carried over from the
runtime version by Matthias Schabel in his original compile-time rational. IOW
to the compile time rational veterans thats how its always been and we thought
it worked fine. The rationale is that rational is primarily a math entity,
whereas integral can be used as an id and for counting, iterating etc. So the
question is do you think they should rather be typedefs for the input

>>> What does that have to do with normalization?
>> Are you referring to my use of the word 'normalisation'
> Yes.
>> to mean making
>> my_rational<2,8>::type == my_rational<1,4>? Maybe the use of the word
>> normalisation here is not correct. Is that the problem?
> No. Please take me literally. I don't see any relationship between
> whether we provide numerator/denominator member typedefs and
> normalisation (or normalization).

As it stands these two typedefs are normalized versions of the Numerator and
Denominator parameters.


>> Its difficult to know what you mean.
>> Do you mean something like:
>> template <
>> typename Numerator,
>> typename Denominator
>> where Denominator == One
>> struct my_rational : Numerator {/*...*/};
> Yes, something like that. Maybe a silly idea, but not insane.

I experimented with the integral / rational relationship. My view is that it is
unwise to couple the two together too closely. One example is in division.
divides<int<1>,int<2> > isnt the same as divides<int_<1>, rational<2,1> >, That
can only be enforced if there is no hidden conversion from rational to integral.

Andy Little

Boost list run by bdawes at, gregod at, cpdaniel at, john at