• <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 肥仔 閱讀(1350) 評論(0)  編輯 收藏 引用 所屬分類: C++ 基礎

            国产精品99久久久精品无码| 国产日韩欧美久久| 亚洲国产精品成人久久| 色婷婷综合久久久久中文一区二区| av色综合久久天堂av色综合在| 久久精品人人做人人爽97| 日本一区精品久久久久影院| 亚洲欧美精品一区久久中文字幕 | 精品久久久久香蕉网| 久久综合九色综合97_久久久| 国产精品亚洲综合久久| 久久99免费视频| 五月丁香综合激情六月久久| 国产日韩久久久精品影院首页| 五月丁香综合激情六月久久| 亚洲欧美久久久久9999| 国内精品久久久久久久涩爱| 久久丫精品国产亚洲av不卡 | 国产精品久久婷婷六月丁香| 色噜噜狠狠先锋影音久久| 久久久久亚洲精品无码蜜桃 | 久久精品国产亚洲av麻豆蜜芽| 99热都是精品久久久久久| 久久99国产乱子伦精品免费| 亚洲人成网站999久久久综合| 国产成人精品久久亚洲高清不卡| 久久综合亚洲欧美成人| 精品人妻伦九区久久AAA片69| 久久电影网| 久久久久久无码国产精品中文字幕| 国内精品久久久久影院日本| 久久精品国产亚洲av影院| 久久精品国产乱子伦| 久久精品国产亚洲αv忘忧草| 亚洲精品无码久久久| 97视频久久久| 久久香蕉超碰97国产精品| 人妻精品久久无码专区精东影业| 亚洲精品tv久久久久久久久 | 久久久久久毛片免费播放| 国产精品一久久香蕉国产线看观看|