• You want to look for Type Casting. I'm not sure, but I think you can do it implicitly: Long Double numberVar = 1234.5678; String stringVar; stringVar = numberVar;
  • In c, I'd use sprintf In C++, I'd use a string stream
  • You can't convert a long double into a string, but you can *print a representation* of the value of of the double, like so: char val[128]; long double v = 1.999; sprintf(val,"%f",v); WARNING: The %f is a format specifier. This may not be the correct format specifier for your runtime library, you should consult the documentation for your version of sprintf() to determine the correct specifier for a long double. If you don't use the right one, the value printed may be wrong. Also, there's no guarantee that the represented value will be precise... a long double can have a lot of digits after the decimal point, if you don't print them all it will be approximate.

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy