|
Boost : |
Subject: Re: [boost] Multiprecision Review
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2012-06-25 05:45:03
Steven Watanabe wrote:
> On 06/24/2012 10:46 AM, Phil Endecott wrote:
>> If the library had been decomposed into data structures
>> vs. algorithms then perhaps I could have applied the algorithms to my
>> simpler data structures. Unfortunately the library has not been
>> organised in this way, and even if it had done the use of sign-magnitude
>> representation might have scuppered any re-use.
>>
>
> While this is an oft-repeated request on
> this list, I believe that it's fundamentally
> misguided. All algorithms have to be implemented
> in terms of some set of primitives. I'm not
> convinced that there's any reasonable way
> to define requirements for an integer more
> basic than +-*/ etc.
As I've said before, I imagine algorithms that operate on sequences of
"limbs" (as John calls them), e.g. (PSEUDO-CODE)
template <typename ITER, typename OITER>
void add(ITER begin1, ITER end1, ITER begin2, ITER end2, OITER result)
{
bool carry = false;
while (begin1!=end1 && begin2!=end2) {
(carry,*result++) = add_with_carry(*begin1++,*begin2++);
}
}
Regards, Phil.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk