Boost logo

Boost :

Subject: Re: [boost] [review] Multiprecision review (June 8th - 17th, 2012)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-06-29 15:42:41


AMDG

On 06/25/2012 10:44 AM, John Maddock wrote:
>>
>> * line 423: (std::numeric_limits<T>::digits + 1) * 1000L
>> This limits the number of bits to LONG_MAX/1000.
>> I'd like there to be some way to know that as
>> long as I use less than k bits, the library
>> won't have any integer overflow problems. k
>> can depend on INT_MAX, LONG_MAX, etc, but the
>> implementation limits need to be clearly documented
>> somewhere. I really hate the normal ad hoc
>> situation where you just ignore the problem and
>> hope that all the values are small enough to avoid
>> overflow.
>
> If there are really more digits than fit in a long then we'll likely
> have other issues - such as not enough memory to store them all in -
> however, I've added a static_assert and a note to this effect.
>

Taking into account the fact that
numeric_limits::digits is in bits
and the extra factor of 1000, it
only takes 500 KB to run into a
problem when long is 32 bits. This
is small enough that running out
of memory is not necessarily an issue.

In Christ,
Steven Watanabe


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