First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is a known bug, tracked at

The workaround is to convert to a float:

 print(f'{float(val):.2f}')
click to hide/show revision 2
No.2 Revision

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}')