from decimal import Decimal

'%.2E' % Decimal('40800000000.00000000000000')

# returns '4.08E+10'

In your '40800000000.00000000000000' there are many more significant zeros that have the same meaning as any other digit. That's why you have to tell explicitly where you want to stop.

If you want to remove all trailing zeros automatically, you can try:

def format_e(n):
    a = '%E' % n
    return a.split('E')[0].rstrip('0').rstrip('.') + 'E' + a.split('E')[1]

format_e(Decimal('40800000000.00000000000000'))
# '4.08E+10'

format_e(Decimal('40000000000.00000000000000'))
# '4E+10'

format_e(Decimal('40812300000.00000000000000'))
# '4.08123E+10'
Answer from eumiro on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › display-scientific-notation-as-float-in-python
Display scientific notation as float in Python - GeeksforGeeks
July 23, 2025 - str.format() formats the number as a float, followed by "e+" and the appropriate power of 10. For example- 340 will be displayed as 3.4e+2 · Example: -51000000000.0000000 in scientific notation results in "5.10e+10",where the no. after "e+"denotes ...
Discussions

Best way to handle floats in scientific notation form?
You can treat them the same way you treat any other float. If by "spit them out" you mean string conversion / printing, you can format them with the 'e' option. >>> data = 6.25e+008 >>> data *= 3.14 >>> print(f"{data:.2e}") 1.96e+09 https://docs.python.org/3/library/string.html#format-specification-mini-language More on reddit.com
🌐 r/learnpython
6
1
September 3, 2022
How do I convert scientific notation number to float?
It is already a float. If you want a str with fixed decimals then you should use float formatting. One way to do this is f"{num:.20f}" More on reddit.com
🌐 r/learnpython
14
84
March 25, 2022
Is there ANY way to turn off the automatic scientific notation conversion?
Your 'very large numbers' doesn't have enough precision for you to see every digit. Use the decimal module instead. More on reddit.com
🌐 r/learnpython
7
2
December 14, 2022
How to convert scientific notation string to integer?
using an integer for scientific notation probably isn't what you want. Use a float. float('1.77e16') More on reddit.com
🌐 r/learnpython
5
1
November 6, 2022
🌐
TutorialsPoint
tutorialspoint.com › display-scientific-notation-as-float-in-python
Display scientific notation as float in Python
July 31, 2023 - In this code, the float() function converts the number in scientific notation to a float format, and the format() method formats the float with two decimal places. The "g" format specifier in Python automatically chooses between fixed and scientific notation based on the number.
🌐
Scaler
scaler.com › home › topics › python scientific notation
Python Scientific Notation - Scaler Topics
October 10, 2025 - If we have to format 0.000009732 in Python scientific notation then the code for it will be · Here the {:e} in the string is the key point to represent a float value in Scientific Notation while printing the number.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.format_float_scientific.html
numpy.format_float_scientific — NumPy v2.2 Manual
>>> import numpy as np >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.format_float_scientific.html
numpy.format_float_scientific — NumPy v2.4 Manual
>>> import numpy as np >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.format_float_scientific.html
numpy.format_float_scientific — NumPy v2.1 Manual
>>> import numpy as np >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
Find elsewhere
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.format_float_scientific.html
numpy.format_float_scientific — NumPy v2.5.dev0 Manual
>>> import numpy as np >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
🌐
Syntx Scenarios
syntaxscenarios.com › home › python › python scientific notation: how to use, convert & remove it
Python Scientific Notation: How to Use, Convert & Remove it
2 weeks ago - For this, you can cast the number as an float or decimal or int according to your needs. Python will automatically handle the conversion, but sometimes, for better readability, you might want to format it explicitly. ... The code below converts a scientific notation into a float, decimal and integer form using type casting.
🌐
Delft Stack
delftstack.com › home › howto › python › scientific notation python
Scientific Notation in Python | Delft Stack
March 11, 2025 - Here’s how you can use f-strings ... a small floating-point number, 0.000123456. By utilizing an f-string, we format this number to two decimal places in scientific notation....
🌐
Python.org
discuss.python.org › ideas
New format specifiers for string formatting of floats with SI and IEC prefixes - Page 2 - Ideas - Discussions on Python.org
May 20, 2023 - I was thinking of writing a PEP to support formatting floats with SI (decimal) and IEC (binary) prefixes natively for float (and maybe other types if makes sense) but wanted to feel it out first. I’ve implemented what I…
🌐
datagy
datagy.io › home › python posts › python scientific notation: converting and suppressing
Python Scientific Notation: Converting and Suppressing • datagy
October 24, 2022 - Let’s see how we can create the value of 342 using it’s scientific notation counterpart: # Creating a Value From Scientific Notation value = float(3.42e2) print("value as float: ", value) print(f"value as scientific notation: {value:e}") ...
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › format.html
format — Python Reference (The Right Way) 0.1 documentation
>>> #This example illustrates the use of [type] option on integers >>> format(2, 'b') '10' >>> format(2, 'b') '10' >>> format(2, 'c') '\x02' >>> format(2, 'd') '2' >>> format(100, 'o') '144' >>> format(100, 'x') '64' >>> format(100, 'n') '100' >>> format(100) '100' >>> #This example illustrates the use of [type] option on floats >>> format(3.13592, 'e') '3.135920e+00' >>> format(3.13592, 'E') '3.135920E+00' >>> format(3.13592, 'f') '3.135920' >>> format(3.13592, 'g') '3.13592' >>> format(3.13592, '.2g') '3.1' >>> format(3.13592, '%') '313.592000%' >>> format(3.13592, '.2%') '313.59%' >>> format(3.13592, 'n') '3.13592'
🌐
AskPython
askpython.com › home › suppressing scientific notation in python for float values
Suppressing Scientific Notation in Python for Float Values - AskPython
April 29, 2023 - In Python, you can suppress scientific notation when printing float values by using the format function.
🌐
TutorialsPoint
tutorialspoint.com › python-program-to-convert-float-to-exponential
Python program to convert float to exponential
August 29, 2023 - In this approach, we will use the:e format specifier to format the float number in exponential notation. The :e format specifier tells Python to display the number in scientific/exponential notation.
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.format_float_scientific.html
numpy.format_float_scientific — NumPy v2.0 Manual
>>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024'
🌐
Finxter
blog.finxter.com › how-to-print-a-float-without-scientific-notation-in-python
How to Print a Float Without Scientific Notation in Python? – Be on the Right Side of Change
The best way to print even small float numbers is to use f-strings, i.e., special types of formatting string that are enclosed in f'...'. Within a given f-string, you can use the {...:.12f} format specifier to tell Python to use floating point precision with 12 digits after the decimal point.