• 编程判读此系统是大端还是小端


    //判断此系统是大端还是小端的
    //一个32位四字节的整数值,例如1,实际的计算机编码表示 是 0x00000001
    //小端系统中在内存中的表示是 01 00 00 00
    //大端系统中在内存中的表示是 00 00 00 01
    #include <iostream>
    using namespace std;
    union EndianTest {  //union:共用内存地址
        int8_t u[4];    //8位整型的数组
        int32_t i;      //32位整型
    };
    
    static bool isLittleEndianSystem() {
        EndianTest et;
        et.i = 1;
        return et.u[0] == 1;
    }
    int main(int argc, char **agrv) {
        if(isLittleEndianSystem())
            cout << "This system is little endian
    ";
        else
            cout << "This system is big endian
    ";
        return 0;
    }
    
  • 相关阅读:
    微信消息类型和事件类型
    lnmp环境搭建脚本
    laravel框架踩过的坑
    vue结构详解
    PHP消息队列实现及应用
    laravel 运行错误
    笔记分享
    cf730e
    cf 730i
    cf 731f
  • 原文地址:https://www.cnblogs.com/isChenJY/p/11510245.html
Copyright © 2020-2023  润新知