Ask Your Question

Revision history [back]

This is a known bug, tracked at

The workaround is to convert to a float:

 print(f'{float(val):.2f}')

This is a known bug, tracked at

The workaround is to Two workarounds exist:

  • either convert to a float:

     sage: val = 12.3
    sage: print(f'{float(val):.2f}')
    
  • or use a raw float from the start

    sage: val = 12.3r
    sage: print(f'{val:.2f}')