0

Intro

I want to program a parser on Windows in C++ that parses a binary file. It is a star catalog that stores the data in its own binary format (see http://tdc-www.harvard.edu/catalogs/bsc5.html).

Various binary files are made available, each with the following information:

  • Sun/Mac byte order
  • Sun/Alpha byte order
  • PC byte order

Problem

I know the difference between big and little endian, but the terms Sun/Mac, Sun/Alpha and PC byte order mean nothing to me. How can an already with bytes filled file have an PC byte order? What is PC (my current PC or Mac or IBM etc.) and what byte order should I proceed with?

Dawid
  • 477
  • 3
  • 14
  • 3
    [Read and become enlightened](https://en.wikipedia.org/wiki/Endianness). – tadman Dec 11 '22 at 16:57
  • For example, the question of what "PC byte order" means is not answered there. – Dawid Dec 11 '22 at 16:59
  • As above, plus _"...difference between big and little endian..."_ there are more than 2 types of endianness. – Richard Critten Dec 11 '22 at 17:00
  • 1
    It absolutely is, so long as you know what you mean by "PC". If that's x86, then it's in there. That term used to mean "Personal Computer", as in an Apple ][ (6502), only later to be used by IBM to represent their 5150 (8088) computer. The endianness of a "PC" has flipped back and forth *many* times in the last 40 years, and has again with the advent of ARM on the desktop. – tadman Dec 11 '22 at 17:00
  • 2
    the wording in that catalog is silly. Just use big/little/middle (or specifically PDP-11) endian. Or follow [boost convention](https://www.boost.org/doc/libs/develop/libs/predef/doc/index.html#_boost_endian) – phuclv Dec 11 '22 at 17:05
  • @Dawid: "*For example, the question of what "PC byte order" means is not answered there.*" That's because it's a made-up synonym for "endian". – Nicol Bolas Dec 11 '22 at 17:28
  • @tadman: "*The endianness of a "PC" has flipped back and forth many times in the last 40 years, and has again with the advent of ARM on the desktop.*" ARM chips can work just fine as little-endian. And many desktop ARM chips are little-endian chips. – Nicol Bolas Dec 11 '22 at 17:29
  • Search the internet for "Sun byte ordering" and "Mac Byte ordering". Also try searching the internet for "Sun Alpha byte ordering". – Thomas Matthews Dec 11 '22 at 19:04
  • 1
    "PC Byte Order" is probably an old-school way of saying "Little Endian". It was probably used to differentiate Intel based PC's from the "Unix Workstations" like Sparc, AIX, and SGI devices. Even Mac's back in the 90's running Motorola chips were Big Endian. Hence, "Sun/Mac byte order" means "Big Endian". I'm guessing "Sun/Alpha" is another Big Endian as well. The authors of those files and tools should have just settled on one endianness and had the tools themselves handle "flipping the bytes" as appropriate based on architecture. – selbie Dec 12 '22 at 08:01
  • @selbie I was hoping for such an answer. Thanks. – Dawid Dec 12 '22 at 08:16
  • Better duplicate: [Endianness of "IBM PC" byte order?](https://stackoverflow.com/questions/1192030/endianness-of-ibm-pc-byte-order) – Mark Rotteveel Dec 12 '22 at 11:08
  • @MarkRotteveel So "PC byte order" == "IBM PC byte order" == little-endian is always true? – Dawid Dec 12 '22 at 12:14
  • 1
    @Dawid Yes. It has been pretty much accepted usage since the mid-80's that the term "PC" refers to an IBM PC compatible (i.e. 8086/8088, in most cases using MS-DOS/PC-DOS or Windows) or a successor (using 80186, 80286, 80386, 80486, Pentium, etc), which are all little endian. In other words, although the term "personal computer" generally referred to computers for personal use, its abbreviation PC has come to refer to a more specific type of personal computer (usually in contrast with a Mac, the only other type of personal computer to survive). – Mark Rotteveel Dec 12 '22 at 12:22
  • @MarkRotteveel Great!, then I know that the data with the PC byte order must be little endian. If you like, you can provide me with an answer so that I accept it. – Dawid Dec 12 '22 at 12:24
  • That said, I would expect most people to use little endian instead of "PC byte order" these days. Also, carefully check the context to verify they don't mean "host byte order", which means "the native byte order of the platform" (i.e. little endian for x86, big endian for (older) SPARC, PowerPC, etc) – Mark Rotteveel Dec 12 '22 at 12:27

0 Answers0