Does stream I/O support "%a" floating-point format?

Discussion in 'C++' started by John Friedland, Jul 21, 2006.

  1. 'printf' has a '%a' conversion for floating-point output:

    > The `%a' and `%A' conversions are meant for representing
    >floating-point numbers exactly in textual form so that they can be
    >exchanged as texts between different programs and/or machines. The
    >numbers are represented is the form [`-']`0x'H`.'HHH`p'[`+'|`-']DD.


    For example, printing '123456' with "|%13.4a|" produces

    | 0x1.e240p+16|

    I've looked through Josuttis and the header files, but I can't find
    any flags or manipulators that could handle this. Is this possible
    with stream I/O?

    Supplementary question: does anyone know how to search for a '%a' in
    Google groups?

    Thanks -

    John
     
    John Friedland, Jul 21, 2006
    #1
    1. Advertising

  2. John Friedland

    Pete Becker Guest

    John Friedland wrote:
    > 'printf' has a '%a' conversion for floating-point output:
    >


    The %a and %A conversion specifiers are new in C99. C++ is based on C90,
    so as it stands now, it doesn't have them. TR1 adds them, and that's one
    of the parts of TR1 that's been added to the working draft for the next
    version of the C++ standard.

    But in practice, if your C library supports them, they'll work in C++, too.
     
    Pete Becker, Jul 21, 2006
    #2
    1. Advertising

  3. John Friedland

    P.J. Plauger Guest

    "Pete Becker" <> wrote in message
    news:...

    > John Friedland wrote:
    >> 'printf' has a '%a' conversion for floating-point output:
    >>

    >
    > The %a and %A conversion specifiers are new in C99. C++ is based on C90,
    > so as it stands now, it doesn't have them. TR1 adds them, and that's one
    > of the parts of TR1 that's been added to the working draft for the next
    > version of the C++ standard.
    >
    > But in practice, if your C library supports them, they'll work in C++,
    > too.


    Right. Our current product, which includes full TR1 support, also provides
    the manipulator hexfloat, so you can insert hexadecimal format
    floating-point
    values into a stream. As Pete says, both %a in printf and hexfloat in
    iostreams are part of TR1 and will be part of the next C++ Standard.

    P.J. Plauger
    Dinkumware, Ltd.
    http://www.dinkumware.com
     
    P.J. Plauger, Jul 21, 2006
    #3
  4. John Friedland

    P.J. Plauger Guest

    "Pete Becker" <> wrote in message
    news:...

    > John Friedland wrote:
    >> 'printf' has a '%a' conversion for floating-point output:
    >>

    >
    > The %a and %A conversion specifiers are new in C99. C++ is based on C90,
    > so as it stands now, it doesn't have them. TR1 adds them, and that's one
    > of the parts of TR1 that's been added to the working draft for the next
    > version of the C++ standard.
    >
    > But in practice, if your C library supports them, they'll work in C++,
    > too.


    Right. Our current product, which includes full TR1 support, also provides
    the manipulator hexfloat, so you can insert hexadecimal format
    floating-point
    values into a stream. As Pete says, both %a in printf and hexfloat in
    iostreams are part of TR1 and will be part of the next C++ Standard.

    P.J. Plauger
    Dinkumware, Ltd.
    http://www.dinkumware.com
     
    P.J. Plauger, Jul 21, 2006
    #4
  5. Thanks guys -

    John
     
    John Friedland, Jul 21, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H aka N
    Replies:
    15
    Views:
    15,794
    Ben Jones
    Mar 2, 2006
  2. Motaz Saad
    Replies:
    7
    Views:
    6,533
  3. Replies:
    4
    Views:
    1,325
    Default User
    Feb 22, 2006
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,390
    Saraswati lakki
    Jan 6, 2012
  5. teeshift
    Replies:
    2
    Views:
    285
    Chris Pearl
    Dec 1, 2006
Loading...

Share This Page