标签: c++ c++11
我有两个整数,我想将它们放入一个32位数字,这样0到16的第一位将用于第一个数字,17到32个其他位用于另一个数字。怎么做这个工作?
答案 0 :(得分:0)
int32_t i32 = (int32_t)( (uint32_t)s1<<16 | (uint32_t)s2 );
另见Cleanest way to combine two shorts to an int