Convert char to double

Ashton picture Ashton · Jun 17, 2013 · Viewed 7.8k times · Source


I am writing a code for data acquisition for my hardware.

However, I need to find the average of the data that I have collected.

Here's the problem, the acquired data is in unsigned char format and I need to convert it to double format. Furthermore, the data collected is in exponential form [1.789232E-05].

Is there any possible way of converting a unsigned char to double then back again??

I have got a double j and a unsigned char a[200]
The unsigned char consist of 1.789232E-05. How do I convert that data to double?

Thank you!

Answer

Ionut Daniel picture Ionut Daniel · Jun 17, 2013

you could try to use atof for converting from char to double ,as for representing an double to an char I suggest you use char* to store the converted double.

Link to atof from msdn : http://msdn.microsoft.com/en-us/library/hc25t012%28v=vs.71%29.aspx