add without carry

Marc 'BlackJack' Rintsch bj_666 at
Fri Sep 15 11:19:20 CEST 2006

In <1158308274.680123.100070 at>, 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.

Your description is a bit vague.  What is `without carrying`?  Do you want
to limit the result to a given bit length with a "wrap around" behavior if
the number gets too large to fit into those bits?  Then this should do the

  a = (b + c) & (2**bits - 1)

	Marc 'BlackJack' Rintsch

More information about the Python-list mailing list