add without carry

Bruno Desthuilliers onurb at xiludom.gro
Fri Sep 15 07:48:44 EDT 2006


Christophe wrote:
> Bruno Desthuilliers a écrit :
>> Bryan Olson wrote:
>>> Hugh wrote:
>>>> Sorry, here's an example...
>>>>
>>>> 5+7=12
>>>>
>>>> added without carrying, 5+7=2
>>>>
>>>> i.e the result is always less than 10
>>> Are you looking for bitwise exclusive or? In Python it's
>>> the '^' operator. For example:
>>>
>>>     print 5 ^ 7
>>>
>>>
>>>>> 10 ^ 21
>> 31
>>
>> Not really "less than 10"...
> 
> But you must use numbers smaller than 10 as input! Still :
> 
>>>> 8 ^ 2
> 10
> :D

Still fails:
>>> 8 ^ 7
15

Sorry !-p



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list