ethereum / solidity-examples

Loose collection of Solidity example code
MIT License
534 stars 160 forks source link

Endianness section is wrong/misleading #54

Closed roshanr95 closed 3 years ago

roshanr95 commented 4 years ago

Bytes.md has a section which says "Ethereum uses the big endian format when working with strings/bytes, and little endian when working with other types (such as numbers and addresses)." and proceeds to give examples of the same, but it doesn't match conventional use of the term endianness.

I'm not sure if there's an ideal term for what its trying to demonstrate (something around padding maybe?), perhaps someone more knowledgeable can chime in here.

chriseth commented 4 years ago

Indeed, Ethereum is big-endian everywhere, but strings are left-aligned why numbers are right-aligned.

roshanr95 commented 4 years ago

Ah yes, the concept of alignment would fit pretty well.

The ABI spec here seems to use versions of "padded on left/right" in most places and "left-align" in one of the examples so using either would be fine.

yipu3 commented 2 years ago

Thanks! This is accurate and useful.