Boost logo

Boost :

Subject: Re: [boost] Algebraic abstractions related to (big) integers in C++
From: pavel (paul.cpprules_at_[hidden])
Date: 2011-03-31 11:59:25


 Phil wrote on Thursday, March 31, 2011 at 4:51:18:
> I came to the conclusion that it is better to write multi-word addition
> code (like the above) in assembler for each platform.

> I believe that the issues are similar on other architectures that have
> a flag register, but maybe others can confirm or deny that.

> Any thoughts anyone?

taking into account luke's message about adc_pi, i think that it's a
perfect opportunity to abstract multiword addition (with carry) like
this:

  unsigned add_with_carry(unsigned *dest, const unsigned *src, size_t size);

the returned value is intended to be an overflow flag (read: carry of
the result of the most significant word addition)

that is the returned value is 0 or 1 (or even 2)

obviously, inside the function one may implement any incredible (asm?)
code (possibly involving sse/avx/altivec/etc.)

-- 
Pavel
P.S.
if you notice a grammar mistake or weird phrasing in my message
please point it out

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