Why are the following two similar prints slightly different and how fix?
>>> x = 0x739ad43ed636
>>> print(x + (-x) // 2048)
127046758190683
>>> print(x - x // 2048)
127046758190684
I'm working in an area where such deviations matter. It would nice to
understand what is happening.
Any help
Thanks. I didn’t post new code. I was just referring back to original
post. I need to duplicate the exact behavior of Java’s BigIntegers.
I’m guessing difference between Java and Python is that Java BigIntegers do
not switch to floor for negatives.
Possible to tweak rounding of Python to be li
On 30Dec2018 23:33, Christian Seberino wrote:
Thanks. I didn’t post new code. I was just referring back to original
post.
I think Ian looked up the first post on Google Groups, where your code
was evident. The message was incomplete when it got here (the mailing
list); I don't know why.
On Mon, 31 Dec 2018 at 09:00, Christian Seberino wrote:
>
> Thanks. I didn’t post new code. I was just referring back to original
> post. I need to duplicate the exact behavior of Java’s BigIntegers.
>
> I’m guessing difference between Java and Python is that Java BigIntegers do
> not switch to
Thanks to all who helped. As was previously pointed out, many other languages
use truncation rather than rounding for // division.
Getting the behavior you want may be as easy as replacing // with the int()
function
>>> x = 9 ; y = 2
>>> x // y, -x // y, (-x) // y
(4, -5, -5)
>>> int(x /