Printf with Thousands Separators

saullipton
2021-01-19
2021-01-22
  • saullipton - 2021-01-19

    Hello,
    I would like to output floating point numbers that include the thousands separators. In the US they would be commas",". For example, using %f with 12345.67 should yield "12,345.67". Is this possible without manually separating the number into strings? For example, can we set a locale that would specify the separators? Can we use printf to format the string correctly?
    Thanks!

     
  • m.prestel - 2021-01-22

    Hello @saullipton,

    internally printf is used for most of the formatting.
    I did not find any flag to print out the number in the US style.

    Best regards,
    Marcel

     

    Last edit: m.prestel 2021-01-22

Log in to post a comment.