字节序的编程语言字节、编程语言

2023-09-04 09:27:28 作者:保持90°的微笑丶是唯美

那么,字节序的主题总是有点混乱给我,但我从来没有遇到这需要我别想二进制作家/读者,我用的默认行为的任何问题。我写一个PNG去codeR在C#现在。 PNG文件格式规范规定,所有号码都存储在大端符号(我觉得这很自然)。但是,我感到非常惊讶,当我注意到,那.NET的BinaryReader在/写卡器的工作原理与小尾数符号。有什么困惑我还要多,是事实,Java的二进制IO适用于大端符号(一个我不是一个Java程序员,所以也许我错了)。于是我开始思考以下几个问题:

Well, the "Endianness" theme was always a little bit confusing to me, but i have never faced any problems which required me to even think about the default behaviour of binary writers/readers that i used. I am writing a PNG decoder in c# right now. PNG file format specification states that all numbers are stored in a big endian notation (which i find very natural). However, i was very surprised when i noticed, that .NET's BinaryReader/Writer works with a little endian notation. What confused me even more, was the fact, that java's binary IO works with a big endian notation (a am not a java programmer, so maybe i am wrong). So i started to think about the following questions:

1 - 为什么事情,因为他们是谁?我指的是基类库默认行为。 2 - 为什么没有使用.NET的System.IO的时候没有办法选择一个preferred符号

1 - Why are things as they are? I mean a Base Class Library default behaviour. 2 - Why there is no way to choose a preferred notation when using .NET's System.IO ?

我目前使用乔恩斯基特的的 MiscUtil 和它的作品就像一个魅力(感谢,男子=))。但是,如果冷静地看到在基类库这个功能。

I am currently using Jon Skeet's MiscUtil and it works like a charm (thanks, man =) ). But it would be cool to see this functionality in a Base Class Library.

推荐答案

这是因为code是为了在最重要的平台上运行尽可能的好。 C#/。NET是由微软和在x86平台上运行居多。 86是小尾数,因此是很有意义使图书馆小端。 Java是由Sun制作和Sun SPARC是大端,因此Java标准是大端以及。

This is because the code is meant to run as good as possible on the most important platform. C#/.NET is from Microsoft and runs mostly on x86 platforms. x86 is little-endian, so it makes sense to make the library little-endian. Java is made by Sun, and the Sun SPARC was big-endian, thus Java standard was big-endian aswell.