Home > Back-end >  How can I get a correct decimal results for a Python modulo operation (without extra libs)?
How can I get a correct decimal results for a Python modulo operation (without extra libs)?

Time:12-13

I am trying to get a correct decimal (not scientific) expression for the following equation. It seems, by default, Python prints the scientific notation. I am using Python on an embedded system, so I cannot easily install libs. I am looking for a default way to get the correct result.

>>> 4292739359**(-1) % 4292739360
2.329514830439068e-10

The correct expression is 4292739359. Python seems to show different results.

CodePudding user response:

The Python equivalent is using pow:

>>> pow(4292739359, -1, 4292739360)
4292739359
  • Related