Boost logo

Boost :

Subject: Re: [boost] [Review Request] Multiprecision Arithmetic Library
From: Andrii Sydorchuk (sydorchuk.andriy_at_[hidden])
Date: 2012-04-03 18:49:46

> 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;

> 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? 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.


Unsubscribe & other changes:

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