[英]c convert uint32_t casted to int32 saved to file and read the uint32_t agein
I have made a C program to log some data. 我做了一个C程序来记录一些数据。
I get a timestamp in uint32_t format. 我得到了uint32_t格式的时间戳。
I then saved the data using afprintf("%d",timestamp) this means that it made a cast from the unsigned integer to an signed integer, and therefore i got some numbers which are way of. 然后,我使用afprintf(“%d”,timestamp)保存了数据,这意味着它从无符号整数到有符号整数进行了强制转换,因此我得到了一些数字。
My question is then. 我的问题是。 how do i compute it back to the original unsigned integer.
我如何将其计算回原始的无符号整数。 preferable in ac# program.
在ac#程序中更可取。 but anything will do.
但是一切都会做。
why not save it with fprintf("%u",timestamp) which is meant for unsigned ints? 为什么不使用fprintf(“%u”,timestamp)来保存它,它用于无符号整数?
but casting in general is done like this: 但一般来说,投射是这样完成的:
unsigned int a;
int b = -1;
a = (unsigned int )b; // a should now be 4294967295
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.