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
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
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
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 '^'
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...
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
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:
>>
>>
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
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
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
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
Thankyou everyone this gives me something to work with.
Hugh
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
18 matches
Mail list logo