-
Book Overview & Buying
-
Table Of Contents
Mastering Swift 6 - Seventh Edition
By :
In computer terminology, the endianness refers to the arrangement of bits in memory. Endianness is typically classified as either big-endian or little-endian. In a little-endian architecture, the least significant bit is stored at the lowest memory address, whereas in a big-endian architecture, the most significant bit occupies the lowest memory address.
When utilizing the Swift standard library or solely working within the Swift language, concerns about bit storage are generally unnecessary. However, when interfacing with low-level C libraries across different architectures, understanding how data is stored becomes essential, particularly when dealing with memory pointers.
For instances where endianness matters, Swift offers built-in instance properties for integers, named littleEndian and bigEndian, to assist in handling endianness-related issues. The following example shows how to use these properties:
let en = 42
print("Little-endian representation", en.littleEndian...