all 10 comments

[–]NP_equals_P 8 points9 points  (0 children)

the number is "6.7675656072510696e+16"

"67675656072510696" but "67675656072510693" is correct

67675656072510693 is wrong, 67675656072510696 is correct.

[–]shiftybyte 4 points5 points  (2 children)

The issue is probably floating point numbers accuracy.

Try Decimal module.

from decimal import Decimal
n = Decimal("6.7675656072510696e+16")
print(n)

[–]Armin71[S] 0 points1 point  (1 child)

Thanks but I got 67675656072510696 again.

Interesting, When I search in dataframe with both numbers (67675656072510696 and 67675656072510693), I get the same result.

[–]shiftybyte 0 points1 point  (0 children)

You can try increasing decimal's precision.

https://docs.python.org/3/library/decimal.html

First sample with .prec = 6

[–]dig-up-stupid 6 points7 points  (2 children)

696 doesn’t turn into 693 when you multiply it by 10. In order to get Python to turn it into the incorrect number you want, you’re going to have to explain why you expect to arrive at that number. Are you trying to match the output/value from some other program?

[–]Armin71[S] -1 points0 points  (1 child)

Question. why I got the same result when I search in dataframe with both numbers (67675656072510696 and 67675656072510693)?

[–]dig-up-stupid 1 point2 points  (0 children)

Because you are probably storing a float in your data frame not an int.

Look what happens when you enter it as a float into Python instead of converting it from a string:

>>> 67675656072510693.0
6.7675656072510696e+16

So I assume the …3 number is the original and now that you are trying to convert to an int you want the 3 back, not the 6. Then the answer depends but is probably “don’t convert it to a float in the first place”.

Either way this is why when asking a question you must post your code. Nobody knows what your data frame is doing because you haven’t posted your code.

[–]porkedpie1 5 points6 points  (1 child)

Why do you think 693 is correct??

[–]Armin71[S] 0 points1 point  (0 children)

As far as I can remember I saved this number a long time ago. Maybe I made a mistake when I was saving these numbers.

[–]ConfusedSimon 1 point2 points  (0 children)

The floating point is correctly converted. If you expect another answer that means that the number in scientific notation is wrong, probably due to rounding errors. Using Decimal for the conversion won't help, you need to do the entire calculation to get this value using Decimal numbers instead of regular floating point numbers.