【问题标题】:What is the best alternative datatype for (unsigned int) that can be of the same size across 32/64 bit platforms?在 32/64 位平台上可以具有相同大小的 (unsigned int) 的最佳替代数据类型是什么?
【发布时间】:2015-05-31 20:54:18
【问题描述】:

我正在 64 位机器上开发,我意识到 unsigned long 在 64/32 平台上没有相同的大小。在保持最大可能数据范围的同时,它的替代方法是什么?

【问题讨论】:

    标签: casting 32bit-64bit type-conversion


    【解决方案1】:

    使用 uint64_t 你确定每个人都一样

    #include <stdint.h> 
    uint64_t my_number;
    

    【讨论】:

    • 然后我进行类型转换?
    • 你应该用 uint64_t 替换你所有的 unsigned long。否则你可以转换它们,但它似乎没用,因为你会将小值(长)放在一个大容器(uint64)中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-24
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    相关资源
    最近更新 更多