[Format] How to format floating point values

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Format] How to format floating point values

Boost - Users mailing list
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
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Format] How to format floating point values

Boost - Users mailing list
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
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [Format] How to format floating point values

Boost - Users mailing list
On Sat, Jan 19, 2019 at 5:05 PM Larry via Boost-users
<[hidden email]> wrote:
>
> 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
> > [hidden email]
> > https://lists.boost.org/mailman/listinfo.cgi/boost-users
> >
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users