Link to home
Start Free TrialLog in
Avatar of Neelima
Neelima

asked on

convert float/double to string.

How do I convert a floating point number to string?
Avatar of Neelima
Neelima

ASKER

Will it help to the manipulation at bit level?
Try this (Converting int to string)

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int num=999;
    char str[6]; // a 5 character string

    sprintf(str, "%d", num);

    printf("%s\n", str);

    return EXIT_SUCCESS;
}

Notice of the use of %d for integer. Change that to others for double and long.

hongjun
Avatar of Neelima

ASKER

If I use those options then there is rounding after 6 digits after the decimal point.I dont want that.And I dont want to give any precision too.What I want to know is if this can be manipulated at bit level?
ASKER CERTIFIED SOLUTION
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial