Skip to content

Commit

Permalink
Uses numpy to fix float formatting/rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
gdixon committed May 21, 2021
1 parent 3142cdb commit 68a5f05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/quadraticlands/templatetags/token_format.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django import template

import numpy as np

register = template.Library()

@register.filter
def token_format(value):
return "%.2f" % float(value) if float(value) > 1 else str('{:.18f}'.format(value)).rstrip('0')
return "%.2f" % value if value >= 1 else np.format_float_positional(value)

0 comments on commit 68a5f05

Please sign in to comment.