我正在使用一个图书馆,回收一个有两张时间印章(时间档Hi, 时间档/Lo)<代码>未签字的长期<>。 我只需要印刷版《<条码>%llu条码>的打印时间。
从这两个方面获取数据的最容易的方法是什么,并正确地将其用作第64号数据?
我正在使用一个图书馆,回收一个有两张时间印章(时间档Hi, 时间档/Lo)<代码>未签字的长期<>。 我只需要印刷版《<条码>%llu条码>的打印时间。
从这两个方面获取数据的最容易的方法是什么,并正确地将其用作第64号数据?
假设<代码>长期寄出的在您的平台上是64个轨道类型。
assert(sizeof(unsigned long) * CHAR_BIT == 32);
assert(sizeof(unsigned long long) * CHAR_BIT == 64);
// Static asserts are more appropriate in cases like this
unsigned long long Timestamp = TimestampHi;
Timestamp <<= 32; Timestamp += TimestampLo;
然后打印<代码> 时装/代码>值。
1. 单行
unsigned long long Timestamp = ((unsigned long long) TimestampHi << 32) + TimestampLo;
或者
printf("%llu
", ((unsigned long long) TimestampHi << 32) + TimestampLo);
如果你想从基于轨道的行动中提取你的代码,可以改写这一表述。
TimestampHi * ((unsigned long long) ULONG_MAX + 1) + TimestampLo
unsigned long long t = (unsigned long long)hi << 32 | lo;
printf("%ull
", t);
注:使用<代码>的Im 长期寄出,而不是uint64_t
因为它
printf
- you don t need the PRIu64 macro, and%ull
in the question.然而,如果你想要支持特别志愿人员组织(它并不接近现代标准),那么你可能更能做到:
uint64_t t = (uint64_t)hi << 32 | lo;
printf("%" PRIu64 "
", t);
这样,你就可以确保(通过更换失踪系统头盔)<代码>uint64_t被适当定义为MSVC64-bit unsign类型,PRIu64
被定义为适当的<代码><<>t>/code>格式查询人加以打印。
Andrey回答了您所做的事情,如果您有some 64-bit类型,但也许只有32类。 在此情况下,你需要的是多位校正图书馆。 GNU MP Library是极好的,但为您的目的可能超高。 I8lib 执行“双重”精准精准精准精准精准精度算术(即不超过64 bits)并且可能不作任何罚款。
如果答案少于2^49,而有64英寸铁箱,那么印刷法(“%1.0f”、“4294967296.0*upper_part + 下_part)? 这将在平台上工作,平台的双倍少于64条轨道,但它将在很多平台上工作,没有64条轨道。
For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...
最好、最小、最快、开放的来源、C/C++ 3d 提供方(在3ds max模型的支持下),而不是通用公平市价,
Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...
I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...
I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...
I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...
Is there anything other than DDD that will draw diagrams of my data structures like DDD does that runs on Linux? ddd is okay and runs, just kind of has an old klunky feeling to it, just wanted to ...
Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...