简体   繁体   中英

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM