2017-06-23 3 views

Antwort

2

Sie können die format Filter mit dem Formatierer der sprintf Funktion, wie zB:

{% set foo = 0.00000000751 %} 

{{ "Scientific notation: %e"|format(foo) }} 

{{ "Scientific notation: %g"|format(foo) }} 

Wissenschaftliche Notation: 7.510000e-9

Wissenschaftliche Notation: 7.51e-9

Here ein funktionierendes Beispiel.

0

Ich tat dies nur zwei Ziffern nach dem Koma anzuzeigen:

{{ ("%e"|format(mydouble)) |slice(0, 4)}}{{ ("%e"|format(mydouble)) [8:]}} 
Verwandte Themen