Max
Max

Reputation: 67

How to convert a negative exponential number into a decimal number in Python?

I'm having hard time converting the following numbers for example:

-1.9443404027234424e+46
-1.9443404027234425e+36

in a format without the scientific notation (AKA a float like 0.04256 for example).

Upvotes: 1

Views: 286

Answers (1)

Selcuk
Selcuk

Reputation: 59184

You can use the :f format specifier:

>>> print("{:.0f}".format(-1.9443404027234424e+46))
-19443404027234423757622069004479676797119627264

Note that the result may not end with 46 zeros because of floating point precision.

Upvotes: 4

Related Questions