Skip to content

Endianness of "int"? #315

Answered by scott-griffiths
James-E-A asked this question in Q&A
Discussion options

You must be logged in to vote

Hi. Yes the endianness of the formats is guaranteed.

System big or little endianness is only ever at the byte level, and determines which order the bytes are arranged before interpreting them. There are explicit data types for each of these, e.g. intbe, intle, intne for big, little and native endian signed ints. Note that these types can only work if the interpreted data is a whole number of bytes long, as otherwise it just doesn't make sense.

The ordinary int is bit-wise big-endian, which just means that the right-most bit is the least significant. The int12 is therefore just bit-wise big endian, and will be the same everywhere.

I'd suggest taking a look at how numbers are stored as big …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@James-E-A
Comment options

Answer selected by James-E-A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants