Strange error in python3 when doing big int calculation
NickName:EricY Ask DateTime:2016-09-03T23:01:54

Strange error in python3 when doing big int calculation

I was trying to do this in Python 3.5.2:

int(204221389795918291262976/10000)

but got the unexpected result: 20422138979591827456

It's working fine in Python 2.7.12, result is: 20422138979591829126L

Any idea why Python 3 gave me the wrong result?

Copyright Notice:Content Author:「EricY」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39308302/strange-error-in-python3-when-doing-big-int-calculation

More about “Strange error in python3 when doing big int calculation” related questions

Strange error in python3 when doing big int calculation

I was trying to do this in Python 3.5.2: int(204221389795918291262976/10000) but got the unexpected result: 20422138979591827456 It's working fine in Python 2.7.12, result is: 204221389795918291...

Show Detail

Strange error in python3 when doing big int calculation

I was trying to do this in Python 3.5.2: int(204221389795918291262976/10000) but got the unexpected result: 20422138979591827456 It's working fine in Python 2.7.12, result is: 204221389795918291...

Show Detail

Strange error in python3 when doing big int calculation

I was trying to do this in Python 3.5.2: int(204221389795918291262976/10000) but got the unexpected result: 20422138979591827456 It's working fine in Python 2.7.12, result is: 204221389795918291...

Show Detail

Modulo calculation with big numbers (C#)

today in class we learned that a big modulo calculation can be divided into multiple smaller modulo calculations. The example was 7^5 mod 11 (=10) can be divided into (((5^2) mod11)^2 mod11)*7 mo...

Show Detail

Error in int vba function calculation?

I am doing a calculation of values using Microsoft Excel vba. I have a portion of codes like the below: INT(151.2 * 100) I notice that the result from this calculation is 15119 but the correct re...

Show Detail

Big Oh Logarithmic(ish) complexity calculation

So I've been trying to get a handle on Big Oh calculations. I feel I have the basics down but am stumped on what seems a really easy calculation. So if the calculation below has a big oh of O(n log...

Show Detail

Evaluate calculation with interpretor but value to big

I'm using the BeanShell Interpreter in Java to solve string-calculations. the problem is that I do some parsing by myself which can't be done by the interpreter and store the partial result in an

Show Detail

Avoiding rounding when doing calculation

I've a piece of Java code from here which converts a number to words, it's working fine but the fraction is always 1 less than it should be, ex. 122.11 is printed 122.10. Here is piece of code whi...

Show Detail

Difference between big.Int and *big.Int, and how do you pass a big.Int by value

I can use methods like Text() on a big.Int and it works fine, but if I return a big.Int then use "myfunc().Text()" throws an error, whereas if I return a *big.Int, I get no error. Why can I use Tex...

Show Detail

Big O calculation

int maxValue = m[0][0]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if ( m[i][j] >maxValue ) { ..

Show Detail