Skip to main content
Mohan1
Associate III
Oct 22, 2019 12:42 PM UTC
Solved

Conversion of decimal to string

Hello, I am getting data in decimal format and to need to convert it into string.So how can i do it?

    This topic has been closed for replies.
    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Oct 22, 2019 2:09 PM UTC

    The math/logic here are pretty simple, sort of thing given as a homework assignment to check if you have some grasp of topic.

    Tip:do it backward, generating the least significant digits first.

    Library also has things like itoa() which is more lightweight than sprintf() and variants.

    http://www.cplusplus.com/reference/cstdlib/itoa/

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

    3 replies

    Ozone
    Principal
    Oct 22, 2019 2:02 PM UTC

    sprintf() would be the simplest way.

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Oct 22, 2019 2:09 PM UTC

    The math/logic here are pretty simple, sort of thing given as a homework assignment to check if you have some grasp of topic.

    Tip:do it backward, generating the least significant digits first.

    Library also has things like itoa() which is more lightweight than sprintf() and variants.

    http://www.cplusplus.com/reference/cstdlib/itoa/

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Mohan1
    Mohan1Author
    Associate III
    Nov 1, 2019 5:12 AM UTC

    Thank you so much sir.I used itoa function and it shows correct decimal value in docklight that i required.Thank you once again sir.