      digits = [str(digit) for digit in reversed(digits)]
      while len(digits) <= abs(exponent):
          digits.append('0')
      digits.insert(-exponent, '.')
      if sign:
          digits.append('-')
      number = ''.join(reversed(digits))
      return mark_safe(formats.number_format(number, abs(p)))
  
  
 
</s> remove     sign, digits, exponent = d.quantize(exp, ROUND_HALF_UP, Context(prec=prec)).as_tuple()
 </s> add     rounded_d = d.quantize(exp, ROUND_HALF_UP, Context(prec=prec))
    sign, digits, exponent = rounded_d.as_tuple()
    if sign and rounded_d:
      digits = [str(digit) for digit in reversed(digits)]
      while len(digits) <= abs(exponent):
          digits.append('0')
      digits.insert(-exponent, '.')
    if sign and rounded_d:
          digits.append('-')
      number = ''.join(reversed(digits))
      return mark_safe(formats.number_format(number, abs(p)))
  
  
keep keep keep keep replace keep keep keep keep keep
 Fixed #30761 -- Prevented floatformat filter from returning a negative zero. 
django/template/defaultfilters.py