Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
Jon Ribbens a écrit : > In article <[EMAIL PROTECTED]>, Bruno Desthuilliers 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 >> >>>I've been thinking some more about this and my brain is startin

Re: add without carry

2006-09-15 Thread John Machin
Jason wrote: > Jon Ribbens wrote: > > In article <[EMAIL PROTECTED]>, Bruno Desthuilliers wrote: > > > > > > No need to think too long to come up with the most possibly Q&D solution: > > > > > > res = int(str(5 + 7)[-1]) > > > > Am I missing something subtle in the question or is there some reason

Re: add without carry

2006-09-15 Thread Jason
Jon Ribbens wrote: > In article <[EMAIL PROTECTED]>, Bruno Desthuilliers wrote: > > > > No need to think too long to come up with the most possibly Q&D solution: > > > > res = int(str(5 + 7)[-1]) > > Am I missing something subtle in the question or is there some reason > that nobody has posted the

Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
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 '^'

Re: add without carry

2006-09-15 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Bruno Desthuilliers 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 > >> I've been thinking some more about this and my brain is starting to >> work something out...

Re: add without carry

2006-09-15 Thread Bryan Olson
Bruno Desthuilliers wrote: > 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: >> >> p

Re: add without carry

2006-09-15 Thread Christophe
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: >> >>

Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
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

Re: add without carry

2006-09-15 Thread Bruno Desthuilliers
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 > I've been thinking some more about this and my brain is starting to > work something out... No need to think too long to come up with the most possibly Q&D soluti

Re: add without carry

2006-09-15 Thread Hugh
Peter, That was what I was thinking along the lines of, It's been two years since I finished my CS degree and working in mechanical engineering means I've nearly forgotten it all! :( Thanks, I'll write a function in my app to handle this... Hugh > >>> (5 + 7) % 10 > 2 > > In this context '%' is

Re: add without carry

2006-09-15 Thread Peter Otten
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 > > I've been thinking some more about this and my brain is starting to > work something out... I just wondered if there was a function in python > math to do this a

Re: add without carry

2006-09-15 Thread Hugh
Thankyou everyone this gives me something to work with. Hugh -- http://mail.python.org/mailman/listinfo/python-list

Re: add without carry

2006-09-15 Thread Bryan Olson
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 -- --Bryan -- http://mail.python.org/mailman/listinfo/py

Re: add without carry

2006-09-15 Thread MonkeeSage
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 def add(a, b, c=10): an = a + b if an >= c: an -= c return an add(5, 7) # = 2 ? Regards, Jordan -- http://mail.python.org/mailman/listinfo/python-list

Re: add without carry

2006-09-15 Thread Hugh
Sorry, here's an example... 5+7=12 added without carrying, 5+7=2 i.e the result is always less than 10 I've been thinking some more about this and my brain is starting to work something out... I just wondered if there was a function in python math to do this automatically... Hugh -- http://m

Re: add without carry

2006-09-15 Thread John Machin
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-o

Re: add without carry

2006-09-15 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, 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 w

add without carry

2006-09-15 Thread Hugh
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. Any help would be great. Hugh -- http://mail.python.org/mailman/listinfo/python-list