本文介绍了从S64在C程序转换错误翻番?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在内核:我读的时间价值类型的extern S64延迟;

In kernel : I am reading the time value as type extern s64 Latency;

在用户空间:

extern double latency;
//fp is reading the kernel value (i.e Latency)
fscanf (fp,"%lf", latency);  

如果我读内核S64在用户空间的两倍。有数据丢失的可能性?
该数据类型,我应该用它来获得完整的价值??

If I read s64 from kernel as double in the user space. Is there possibility of data loss ??which data type should I use to get the complete value ??

推荐答案

简短的回答:是的,肯定会有数据丢失

The short answer: Yes, there will definitely be data loss.

想想看,无论是有符号的64位整数( S64 )和双击具有存储64位。但是,而S64仅关心如何整数,一个双击也可以重新present分数。要做到这一点就需要利用一些比特的信息,所以没有办法,它也可以重新present全方位的64位整数。

Think about it, both a signed 64 bit integer (s64) and a double has 64 bits of storage. But whereas the s64 only concerns itself with integers, a double can also represent fractions. To do that it needs to utilize some of the bits for this information, so there is no way that it can also represent the full range of 64 bit integers.

您应该使用的int64_t 从工具链的 stdint.h

You should use int64_t from your toolchain's stdint.h.

这篇关于从S64在C程序转换错误翻番?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 15:58