Skip to content

Commit

Permalink
Merge pull request #254 from nopslip/bugfix/fix-float-rounding
Browse files Browse the repository at this point in the history
Uses numpy to fix float formatting/rounding
  • Loading branch information
thelostone-mc authored May 22, 2021
2 parents 764cf12 + 68a5f05 commit f418d45
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 f418d45

Please sign in to comment.