math - python long integer division error. how do I fix this? -
this problem arose prime factorization function. when try divide long integer integer. gives value in scientific notation. , not correct answer.
18291821821212182811 / 3 = 6.097273940404061e+18
here,
6.097273940404061e+18
same this, 6097273940404061000
6097273940404061000 * 3
must equal 18291821821212182811
but there 189 integer differences.
6097273940404061000 * 3
189 bigger 18291821821212182811
6097273940404061000 * 3 - 18291821821212182811
= 189
so why not give exact number?? thinking python changes form scientific notation floating point , leads arithmetic error. there way around ? there way can tell python not change floating point during calculation if that's problem.
you have use integer division //
:
18291821821212182811 // 3 = 6097273940404060937
Comments
Post a Comment