Hugh wrote:
> I would like to perform an addition without carrying of two integers...
> I've got no idea how to do this in python, although I've been using it
> for web/cgi/db work for a few years now.
>

In multiword addition in assembly language, one uses a normal ADD
instruction on the lowest-order pair of words, and an ADC (or ADDC or
whatever) i.e add *with* carry which adds in the carry bit from the
previous operation for each subsequent pair of words. IOW, addition
*without* carrying is normal, and I don't recall hearing the expression
before ......

Do you possibly mean: add two 32-bit integers such the result fits in
32 bits i.e. discard the generated carry bit, keep the low-order
32-bits?

If so, that's simply (a + b) & 0xFFFFFFFF (in Python as well as a few
other languages).

If you meant a different number of bits, well the answer for 8 bits
would be (a + b) & 0xFF.

Otherwise, you need to provide some examples of two integers and what
"addition without carrying" produces.

HTH,
John

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to