Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

The round filter

The round filter rounds off a float to the specified precision, as follows:

{{ 3.141592653589793238462 | round(1) }} 
3.1 

You can also specify how you want the number to be rounded off, as shown in the following code:

{{ 4.7 | round(1, "common") }} 
5 
{{ 4.2 | round(1, "common") }} 
4 
{{ 4.7 | round(1, "floor") }} 
4 
{{ 4.2 | round(1, "ceil") }} 
5 

The common option rounds such figures in the same way that a person would: Any number at or above 0.5 is rounded up, and any number lower than 0.5 is rounded down. The floor option always rounds the number down and the ceil option always rounds up, regardless of the decimal value.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content