1
a = math.log(123456789123456789)
b = exp(a)
print(int(round(abs(b))))

output:

123456789123457168

There is data loss after doing anitlog please tell me how to avoid it

Boseong Choi
  • 2,566
  • 9
  • 22
  • 1
    This looks like https://stackoverflow.com/questions/538551/handling-very-large-numbers-in-python. I'd say use a `long` type. – dang Mar 22 '20 at 05:57

1 Answers1

0

You can use Decimal from decimal module to handle large numbers:

from decimal import Decimal


a = Decimal(123456789123456789).ln()
b = a.exp()
print(int(round(abs(b))))

Output:

123456789123456789
Chiheb Nexus
  • 9,104
  • 4
  • 30
  • 43