Negative division bug?

  • Thread starter Michael Yanowitz
  • Start date
M

Michael Yanowitz

Hello:

Just wondering if this is a bug, is this as designed,
or do I have to import math or something to make it correct:

I was just screwing around.
and found:-1
Shouldn't it be zero?
1/100 returns 0
but -1/ANY_POSITIVE_INTEGER_NUMBER
returns -1
-4

It behaves correct for positive numbers, but for negative
integers it seems to subtract one from the expected result.


Thanks in advance:
Michael Yanowitz
 
C

casevh

I was just screwing around.
and found:
-1
Shouldn't it be zero?
1/100 returns 0
but -1/ANY_POSITIVE_INTEGER_NUMBER
returns -1

-4

It behaves correct for positive numbers, but for negative
integers it seems to subtract one from the expected result.
That is the intended behavior. Look at the output of divmod().
(-1,99)

Let (q,r) = divmod(d, v) with v > 0, the behavior is chosen so that 0<=
r < v.

casevh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top