Reputation: 83
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!
Upvotes: 1
Views: 7963
Reputation: 153967
"Exponential form" doesn't mean anything concrete. If the data is on 8 bits, it is probably in G.711 format, either A-Law or μ-Law. Depending on which one, you'll have to use a different conversion routine. (In both cases, the 8 bit format is 1 bit sign, 3 bits exponent, and 4 bits mantissa.)
Upvotes: 0
Reputation: 312
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
Upvotes: 3