小编use*_*167的帖子

带有负值的无符号长整数

请参阅下面的简单代码:

#include <iostream>
#include <stdlib.h>

using namespace std;


int main(void)
{
    unsigned long currentTrafficTypeValueDec;
    long input;
    input=63;
    currentTrafficTypeValueDec = (unsigned long) 1LL << input; 
    cout << currentTrafficTypeValueDec << endl;
    printf("%u \n", currentTrafficTypeValueDec);
    printf("%ld \n", currentTrafficTypeValueDec);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

为什么printf()显示带负值的currentTrafficTypeValueDec(unsigned long)?

输出是:

9223372036854775808
0
-9223372036854775808 
Run Code Online (Sandbox Code Playgroud)

c++

5
推荐指数
4
解决办法
8114
查看次数

如何制作64位掩码?

基于以下简单程序,按位左移运算符仅适用于32位.这是真的吗?

#include <iostream>
#include <stdlib.h>

using namespace std;


    int main(void)
    {
        long long currentTrafficTypeValueDec;
        int input;
        cout << "Enter input:" << endl;
        cin >> input;
        currentTrafficTypeValueDec = 1 << (input - 1); 
        cout << currentTrafficTypeValueDec << endl;
        cout << (1 << (input - 1)) << endl;

        return 0;

    }
Run Code Online (Sandbox Code Playgroud)

该计划的输出:

Enter input:
30
536870912
536870912

Enter input:
62
536870912
536870912
Run Code Online (Sandbox Code Playgroud)

我怎么能生产64位掩码?

c++ 64-bit bitmask bit-shift

2
推荐指数
1
解决办法
3131
查看次数

压缩字母数字字符串

有没有办法将长度= 128*2 + 1的字母数字字符串压缩为最短的唯一表示?

language-agnostic algorithm

2
推荐指数
1
解决办法
860
查看次数

标签 统计

c++ ×2

64-bit ×1

algorithm ×1

bit-shift ×1

bitmask ×1

language-agnostic ×1