c string/string to long double

Hi I would like to ask how I can convert string to long double for further calculation in long double format?

Let's say i got
c string phase = 0.000000789 or 507890123.005
and i want to convert from cstring to long double and want to do
Accphase = phase + Accphase //in long double format

How to do that? You could provide solution in C or C++.I could try both.Thanks
Last edited on
Last edited on
1
2
3
4
5
6
7
double result = 0, npos = 1
for x = string_size ; x&&string[x--]!='-' ;
if string[x] != '.' then 
result += (string[x]-48) * npos, npos *= nbase
else
result /= npos, npos = 1
n = (string[0] == '-' ? -n:n)
Topic archived. No new replies allowed.