Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django template roundup scientific notation

I'm trying to convert, eg:

0.00282357936911 to 2.82e-03 and 0.000130076846614 to 1.30e-04

However, when I use the filter {{ data|stringformat:"e" }}, I get

2.823579e-03 and 1.300768e-04

Is there are way to roundup to 2 decimal points?
Many thanks in advance.

like image 919
DGT Avatar asked Dec 01 '25 12:12

DGT


1 Answers

You can use:

{{ data|stringformat:".2e" }}

The.<number> syntax specifies number of decimal points. See reference for more info.

like image 102
Mariusz Jamro Avatar answered Dec 04 '25 04:12

Mariusz Jamro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!