[英]Convert char to double
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. 这是问题,获取的数据是
unsigned char
格式,我需要将其转换为double
格式。 Furthermore, the data collected is in exponential form [1.789232E-05]. 此外,收集的数据呈指数形式[1.789232E-05]。
Is there any possible way of converting a unsigned char
to double
then back again?? 是否有任何可能的方法将
unsigned char
转换为double
然后再返回?
I have got a double j
and a unsigned char a[200]
我有一个
double j
和一个unsigned char a[200]
The unsigned char consist of 1.789232E-05. unsigned char由1.789232E-05组成。 How do I convert that data to double?
如何将该数据转换为双倍?
Thank you! 谢谢!
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. 您可以尝试使用atof从char转换为double,至于将double表示为char我建议您使用char *来存储转换后的double。
Link to atof from msdn : http://msdn.microsoft.com/en-us/library/hc25t012%28v=vs.71%29.aspx 链接到msdn的atof: http : //msdn.microsoft.com/en-us/library/hc25t012%28v=vs.71%29.aspx
"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.
如果数据是8位,则可能是G.711格式,A-Law或μ-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.)
(在这两种情况下,8位格式是1位符号,3位指数和4位尾数。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.