SQLite Forum

Endianness help
Login
> It doesn't even make sense in typical computers to talk about which bit is on the "left" in RAM. The only way you see it as a programmer is the way you'd write the number on paper, least significant digit on the right.

Without disputing that, (particularly as it relates to RAM), the idea of right and left applied to bits within a larger word has been around for over 50 years [a], and I am pretty sure the terms have been applied consistently. All of the dozens of CPU's that I have examined the instruction set for have shift and/or rotate instructions, usually for both directions. (In some, the shift amount is signed so a single instruction covers both directions.) Without exception, a (by 1) **left** shift/rotate moves the most significant bit value, either out of the operand (into the carry flag) or around into the LSB, and the other bit values get a *= 2 promotion. Similarly, a (by 1) **right** shift/rotate moves the least significant bit value and most of the bit values get a /= 2 demotion. 

[a. See [Intel 4004 datasheet](http://datasheets.chipdb.org/Intel/MCS-4/datashts/intel-4004.pdf), where the RAL and RAR instructions appear on page 8-18. The 4004 design began in 1970. CPU's made with discrete logic (or individual transistors or vacuum tubes appeared earlier followed the same convention, for example [CDC 6400+](http://www.textfiles.com/bitsavers/pdf/cdc/6x00/60100000D_6600refMan_Feb67.pdf) with "arithmetic right shift" and "left shift" instructions. ]

Bit endianality within computers has long been well settled; the littlest bit is on the "right", whether it is called bit 0, bit Nw-1, or Chester.