Message226381
| Author |
DenisCrnic |
| Recipients |
DenisCrnic |
| Date |
2014年09月04日.21:40:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1409866820.23.0.262547020156.issue22337@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Modulus is returning wrong remainder when working with negative numbers.
For example 34%-3 should return 1, but it returns -2.
34/-3=-11, remainder: 1, proof: -11*(-3)+1=34 <--- Math logic (works in Java for example)
but python goes like that:
34/-3=12, remainder: -2. proof: -12*(-3)+(-2)=34 <--- Python logic (works)
I know that python is looking for the int which is the closest to the a (a%b), and is divisible with it, but in this case that's not right. it should seek for the closest integer, which is lower than a, in this case 33
If explanation is not clear enough, reply me, i'll take more time to make it clear.
maybe my theory is wrong, and python syntax works better than in Java. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2014年09月04日 21:40:20 | DenisCrnic | set | recipients:
+ DenisCrnic |
| 2014年09月04日 21:40:20 | DenisCrnic | set | messageid: <1409866820.23.0.262547020156.issue22337@psf.upfronthosting.co.za> |
| 2014年09月04日 21:40:20 | DenisCrnic | link | issue22337 messages |
| 2014年09月04日 21:40:19 | DenisCrnic | create |
|