Sam Pollard (2) [Avatar] Offline
In the note at the beginning of Section II - Types, we state that ‘The text “Go” and the number 28487 are both represented with the same zeros and ones on an X86 computer (0110111101000111) ... "

but that first byte = 01101111 = 111 which corresponds to “o” in UTF-8
and the second byte = 01000111 = 71 = “G”
so we seem to be spelling “oG” ?

To spell “Go”, wouldn’t we need to switch the order of the 2 bytes, to form
0100011101101111 = 18287 ??

Apologies if this has been discussed already or if this is just a typo that will be sorted later.
Nathan Youngman (56) [Avatar] Offline
Hi Sam,

Thanks for double checking this. Instead of doing this in my head, I wrote a little program.

The reason the bytes are in this order has to do with little endians on x86. See:

That said, this example doesn't account for a string having a length (Go) or null termination (C). It may be better if I simplify it to a single character (rune) and 8-bits.