zoukankan      html  css  js  c++  java
  • LittleEndian & BigEndian (zz)

    The Basics

    "Little Endian" means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (The little end comes first.) For example, a 4 byte LongInt

        Byte3 Byte2 Byte1 Byte0

    will be arranged in memory as follows:

        Base Address+0   Byte0
        Base Address+1   Byte1
        Base Address+2   Byte2
        Base Address+3   Byte3

    Intel processors (those used in PC's) use "Little Endian" byte order.

    "Big Endian" means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. (The big end comes first.) Our LongInt, would then be stored as:

        Base Address+0   Byte3
        Base Address+1   Byte2
        Base Address+2   Byte1
        Base Address+3   Byte0

    Motorola processors (those used in Mac's) use "Big Endian" byte order.

    Which is Better?

    You may see a lot of discussion about the relative merits of the two formats, mostly religious arguments based on the relative merits of the PC versus the Mac. Both formats have their advantages and disadvantages.

    In "Little Endian" form, assembly language instructions for picking up a 1, 2, 4, or longer byte number proceed in exactly the same way for all formats: first pick up the lowest order byte at offset 0. Also, because of the 1:1 relationship between address offset and byte number (offset 0 is byte 0), multiple precision math routines are correspondingly easy to write.

    In "Big Endian" form, by having the high-order byte come first, you can always test whether the number is positive or negative by looking at the byte at offset zero. You don't have to know how long the number is, nor do you have to skip over any bytes to find the byte containing the sign information. The numbers are also stored in the order in which they are printed out, so binary to decimal routines are particularly efficient.

  • 相关阅读:
    Android TP出现小圆点解决方法
    Android的SAFE MODE(安全模式)
    Linux TCP透传到OneNET
    C读取BMP数据
    OLED显示BMP数据
    电脑出现DNS错误无法上网怎么办
    办公室如果没有网络怎么办呢?
    微信扫一扫获取地理位置
    win10系统程序与功能查找,卸载程序
    手把手学习数据库
  • 原文地址:https://www.cnblogs.com/neoragex2002/p/80067.html
Copyright © 2011-2022 走看看