Which .Net-compatible architectures are not little-endian?

后端 未结 6 1751
醉梦人生
醉梦人生 2021-01-20 11:46

The BitConverter class has a field IsLittleEndian which, according to the documentation:

Indicates the byte order (\"endianness\") in which data is st

相关标签:
6条回答
  • 2021-01-20 12:01

    The XBox360 is BigEndian. Robert Unoki from Microsoft has a good blog post about the importance of checking the IsLittleEndian flag - and the bugs that occurred in porting the CLR to XBox360 when the Microsoft developers failed to do so.

    0 讨论(0)
  • 2021-01-20 12:10

    SOME of the systems that the .NET Micro Framework runs on are (or can be...) big-endian. Version 4.1 introduced support for big-endian architectures.

    You'd probably know if you were running on the micro framework, however...

    0 讨论(0)
  • 2021-01-20 12:16

    The .Net Micro Framework 4.1 supports big-endian - Source

    0 讨论(0)
  • 2021-01-20 12:19

    If you're MSIL you don't get that guarantee.

    Even if it's true for all current architectures, you have no guarantee I don't port .NET to Alpha or PDP11 tomorrow.

    0 讨论(0)
  • 2021-01-20 12:21

    The CLI standard does not proscribe any particular Endianness, so if you want your program to be portable, you should not depend on a particular byte order... unless of course in scenarios where a particular byte ordering is required, such as with some data exchange protocols (thanks to user The Moof for pointing this out).

    From the CLI Annotated Standard (p.161) — Partition I, section 12.6.3: "Byte Ordering":

    For data types larger than 1 byte, the byte ordering is dependent on the target CPU. Code that depends on byte ordering may not run on all platforms. [...]

    I suspect that you saw a hard-coded value for IsLittleEndian in Reflector because when you downloaded/installed the .NET Framework on your machine, that particular installation package was targeted at a particular platform (e.g. Intel x86, which is Little Endian).

    I could thus imagine that there are other installation packages of the .NET framework that have IsLittleEndian hard-wired to return a different value, depending on the platform that particular installation targets.

    0 讨论(0)
  • 2021-01-20 12:24

    Depends on what you mean by ".Net implementations". I'm not aware of Microsoft .NET Framework version for big-endian platform (but see other answers). But if you mean CLI/CLR implementation, then both Mono and DotGNU have versions for big-endian machines. Mono runs at least on Solaris 10 on Sparc and on Mac OS X on PowerPC. DotGNU has much wider list of available platforms.

    0 讨论(0)
提交回复
热议问题