Is it true that whether the architecture is big or little endian ,only the memory layout of numbers differ,that of the string is the same.
Endianness and Character DataIf you store any ASCII character string in memory, it always looks the same, no matter what the Endianness of the hardware, since each character is one byte long and the start character of the string is always stored at the lowest memory location.
Broadly speaking, the endianness in use is determined by the CPU. Because there are a number of options, it is unsurprising that different semiconductor vendors have chosen different endianness for their CPUs.
Endianness is a term that describes the order in which a sequence of bytes is stored in computer memory. Endianness can be either big or small, with the adjectives referring to which value is stored first.
Little Endian Byte Order: The least significant byte (the "little end") of the data is placed at the byte with the lowest address. The rest of the data is placed in order in the next three bytes in memory. In these definitions, the data, a 32-bit pattern, is regarded as a 32-bit unsigned integer.
We write numbers in big endian order And that is unnatural, because in order to read a big number, we need to: jump to the end of a number. scan right-to-left, counting groups of 3 digits, to figure out the order (thousands, millions) then, knowing the order, we can say the number.
Note: Endianness does NOT affect ordering of array elements! However, endianness does affect the ordering of the bytes in each element of the array!
If you have a simple 8-bit character representation (e.g. extended ASCII), then no, endianness does not affect the layout, because each character is one byte.
If you have a multi-byte representation, such as UTF-16, then yes, endianness is still important (see e.g. http://en.wikipedia.org/wiki/UTF-16#Byte_order_encoding_schemes).
For strings of 1-byte characters that is correct. For unicode strings (2 bytes/character) there will be a difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With