Boost logo

Boost :

Subject: Re: [boost] [Review Request] Multiprecision Arithmetic Library
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-04-04 01:30:11


Le 04/04/12 00:49, Andrii Sydorchuk a écrit :
>> What is the result type of operator+ on this upper bound range? Currently
>> the compiler fails.
>
> Following code compiles for me:
>
> template<int N>
> struct big_int {
> big_int() { val = N; }
> template<int M>
> big_int<(N>M?N:M)> operator+(const big_int<M> &that) const {
> return big_int<(N>M?N:M)>();
> }
> int val;
> };
>
> int main() {
> big_int<1> a;
> big_int<2> b;
> std::cout<< (a + b).val<< std::endl;
> std::cout<< (b + a).val<< std::endl;
> }
>
My comment was respect to my library ;-)
>> I hope this answers to your argument against arithmetic operators growing
>> automatically the range of the result.
>
> And do you think this is worth the effort?
Yes. At least for my needs.
> Also I wouldn't like the idea
> of fixed_point<range,0> structures. It is going to be too complicated from
> the user perspective. All I need from fixed integer library is efficient
> fixed integer type (behaving like C++ integral types) and no complex
> structures to compute addition, multiplication, etc.
>
I've not yet defined an specific class for fixed point integers. Note
that the resolution parameter defaults to 0, so that fixed_point<range>
defines an integer. I'll include it once the generic class is stable enough.

Best,
Vicente


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