[C] double/float to string

Discussion in 'C Programming' started by Alan, Mar 7, 2004.

  1. Alan

    Alan Guest

    hi,

    are there any functions that can change double and float to string ?

    and is it possible to change the double/float to string which only contains
    decimal format instead of exponent expression?

    thx
    Alan, Mar 7, 2004
    #1
    1. Advertising

  2. in comp.lang.c i read:

    >are there any functions that can change double and float to string ?
    >
    >and is it possible to change the double/float to string which only contains
    >decimal format instead of exponent expression?


    yes and yes.

    --
    a signature
    those who know me have no need of my name, Mar 7, 2004
    #2
    1. Advertising

  3. Alan wrote:

    > hi,
    >
    > are there any functions that can change double and float to string ?


    sprintf

    > and is it possible to change the double/float to string which only
    > contains decimal format instead of exponent expression?


    sprintf(yourstringgoeshere, "%f", yourdoubleorfloatgoeshere);

    --
    Richard Heathfield :
    "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    K&R answers, C books, etc: http://users.powernet.co.uk/eton
    Richard Heathfield, Mar 7, 2004
    #3
  4. Alan

    Mike Wahler Guest

    "Richard Heathfield" <> wrote in message
    news:c2ei04$5ma$...
    > Alan wrote:
    >
    > > hi,
    > >
    > > are there any functions that can change double and float to string ?

    >
    > sprintf
    >
    > > and is it possible to change the double/float to string which only
    > > contains decimal format instead of exponent expression?

    >
    > sprintf(yourstringgoeshere, "%f", yourdoubleorfloatgoeshere);


    And as to your second question, look up the 'width' and
    'precision' flags for 'printf()' format specifiers.

    -Mike
    Mike Wahler, Mar 7, 2004
    #4
    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. JKop
    Replies:
    4
    Views:
    16,501
  2. Sydex
    Replies:
    12
    Views:
    6,453
    Victor Bazarov
    Feb 17, 2005
  3. bd
    Replies:
    0
    Views:
    605
  4. AviraM
    Replies:
    2
    Views:
    6,330
    Manish Pandit
    Sep 28, 2006
  5. Carsten Fuchs
    Replies:
    45
    Views:
    1,507
    James Kanze
    Oct 8, 2009
Loading...

Share This Page