0

I want to convert numbers like 1.28e+21 to a long digits only number but the following code doesn't make a difference. n = 1.28e+21 b = 1.28*10**21 print(b)

b still has an e.

How do I get rid of e?

diviserbyzero
  • 21
  • 1
  • 6

1 Answers1

3

These numbers in exponential format are from type float in python.You can use int to convert it to an integer.

>>> n = int(1.28e+21)
>>> n
1280000000000000000000

You can also use decimal module like this:

>>> import decimal
>>> decimal.Decimal(1.28e+21)
Decimal('1280000000000000000000')
>>> 
Amir reza Riahi
  • 1,540
  • 2
  • 8
  • 34