[Format] How to format floating point values
Hello, How do I format floating point values, either double or float? I want to specify things like the precision during the formatting, i.e. how many digits to include in the fractional digits, and so forth. Currently, I am using this, for instance: General: "%1$g" Fixed: "%1$f" Scientific: "%1$e" or "%1$E" (depending on whether lower or upper case, respectively) Thanks! Best regards, Michael Powell
It's been a long time since I did it but I used '%.0lf' to format a double with no decimal places. '%6.6s' to format a string with exactly six characters. I am sure there are differences I have forgotten but it is similar to printf. Larry On 1/19/2019 4:32 PM, Michael Powell via Boost-users wrote:
Hello,
How do I format floating point values, either double or float? I want to specify things like the precision during the formatting, i.e. how many digits to include in the fractional digits, and so forth.
Currently, I am using this, for instance:
General: "%1$g" Fixed: "%1$f" Scientific: "%1$e" or "%1$E" (depending on whether lower or upper case, respectively)
Thanks!
Best regards,
Michael Powell _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On Sat, Jan 19, 2019 at 5:05 PM Larry via Boost-users
It's been a long time since I did it but I used '%.0lf' to format a double with no decimal places. '%6.6s' to format a string with exactly six characters. I am sure there are differences I have forgotten but it is similar to printf.
Thanks, I did figure that out after all, but it was a little difficult to drill into the document through the printf notes.
Larry
On 1/19/2019 4:32 PM, Michael Powell via Boost-users wrote:
Hello,
How do I format floating point values, either double or float? I want to specify things like the precision during the formatting, i.e. how many digits to include in the fractional digits, and so forth.
Currently, I am using this, for instance:
General: "%1$g" Fixed: "%1$f" Scientific: "%1$e" or "%1$E" (depending on whether lower or upper case, respectively)
Thanks!
Best regards,
Michael Powell _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Larry
-
Michael Powell