• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            woaidongmao

            文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
            數據加載中……

            判斷big endian和little endian的方法

            Big endian machine: It thinks the first byte it reads is the biggest.

            Little endian machine: It thinks the first byte it reads is the littlest.

            #include <stdio.h>

            int main(int argc, char **argv)
            {
                    union {
                      short  s;
                  char   c[sizeof(short)];
                } un;

                    un.s = 0x0102;
                    if (sizeof(short) == 2) {
                            if (un.c[0] == 1 && un.c[1] == 2)
                                    printf("big-endian\n");
                            else if (un.c[0] == 2 && un.c[1] == 1)
                                    printf("little-endian\n");
                            else
                                    printf("unknown\n");
                    } else
                            printf("sizeof(short) = %d\n", sizeof(short));

                    exit(0);
            }

            總結一下:big endian是適合大家的閱讀順序,little endian則相反。

             

             

             

            /usr/include/中(包括子目錄)查找字符串BYTE_ORDER(或_BYTE_ORDER, __BYTE_ORDER),確定其值。這個值一般在endian.h或machine/endian.h文件中可以找到,有時在feature.h中,不同的操作系統可能有所不同。一般來說,Little Endian系統BYTE_ORDER(或_BYTE_ORDER,__BYTE_ORDER)為1234,Big Endian系統為4321。大部分用戶的操作系統(如windows, FreeBsd,Linux)是Little Endian的。少部分,如MAC OS ,是Big Endian 的。本質上說,Little Endian還是Big Endian與操作系統和芯片類型都有關系。

            Processor OS Order 
            x86 (Intel, AMD, … ) All little-endian 
            DEC Alpha All little-endian 
            HP-PA NT little-endian 
            HP-PA UNIX big-endian 
            SUN SPARC All? big-endian 
            MIPS NT little-endian 
            MIPS UNIX big-endian 
            PowerPC NT little-endian 
            PowerPC non-NT big-endian 
            RS/6000 UNIX big-endian 
            Motorola m68k All big-endian
             

            posted on 2009-09-27 14:32 肥仔 閱讀(1343) 評論(0)  編輯 收藏 引用 所屬分類: C++ 基礎

            国产69精品久久久久久人妻精品| A狠狠久久蜜臀婷色中文网| 99久久国产亚洲高清观看2024 | 亚洲国产综合久久天堂| 热99RE久久精品这里都是精品免费| 一级女性全黄久久生活片免费| 久久综合久久自在自线精品自| 国产亚洲成人久久| 狼狼综合久久久久综合网| 91久久香蕉国产熟女线看| 久久久久亚洲精品日久生情 | 久久无码AV一区二区三区| 久久婷婷五月综合色奶水99啪| 久久久久国产日韩精品网站| 久久人人爽人人爽人人片AV东京热 | 久久精品一区二区| 国产A级毛片久久久精品毛片| 国产精品成人无码久久久久久 | 国产精品99精品久久免费| 精品久久久久久无码不卡| 99久久国产免费福利| 97久久久精品综合88久久| 国产精品久久久久久久app| 一本大道久久a久久精品综合| 日韩av无码久久精品免费| 奇米影视7777久久精品人人爽| 久久国产视频99电影| 一级做a爱片久久毛片| 91精品国产综合久久精品| 国产成年无码久久久免费| 久久这里只有精品首页| 亚洲精品视频久久久| 久久亚洲国产精品123区| 国产高潮国产高潮久久久91| 久久精品国产亚洲欧美| 久久久青草久久久青草| 久久午夜无码鲁丝片| 996久久国产精品线观看| 2021精品国产综合久久| 欧美一区二区精品久久| 国产精品成人无码久久久久久 |