long number devision
I'm just starting to learn python and need a bit of help.
I'm just playing with the calculator functions and if i'm trying to divide a number that is too large I get the following error...
'OverflowError: integer division result too large for a float'
How would I go about dividing a very long number?
It's nothing specific. I see that if I have a long number such as 502746550375606540527365703 (just something random) and I devide by 2 using /2 I get the output 2.5137327518780326e+26 which is obviously not the correct answer to the sum. I guess there is a limit to the characters that can be displayed.
I just wondered how I'd go about working out a sum with large numbers to be calculated?
Thanks for the reply
June 17th, 2016, 02:05 AM
I think that's the correct answer isn't it? The e+26 means the decimal place is moved 26 places to the right. So the real number it's showing is 251373275187803260000000000.
So roughly speaking 502746550375606540527365703 / 2 = 25137327518780326000000000 OR 2.5137327518780326e+26
Although I think this answer is more accurate: 251373275187803270263682851.5
June 20th, 2016, 02:38 PM
Thanks for the explenation, the number with all the 0's i cant see how it can be used in a sum because if you take the number 25137327518780326000000000 & multiply it by 2 you get the answer 5027465503756065000000000 which is a different number to the original.
even if you multiply the more accurate number of 251373275187803270263682851.5 you still dont get the original number. How would you go about deviding the number to give the correct result which can then be multiplied back to get the original?