Files
cppdraft_translate/cppdraft/bit/endian.md
2025-10-25 03:02:53 +03:00

52 lines
1.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[bit.endian]
# 22 General utilities library [[utilities]](./#utilities)
## 22.11 Bit manipulation [[bit]](bit#endian)
### 22.11.8 Endian [bit.endian]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L16022)
Two common methods of byte ordering in multibyte scalar types are big-endian
and little-endian in the execution environment[.](#1.sentence-1)
Big-endian is a format for
storage of binary data in which the most significant byte is placed first,
with the rest in descending order[.](#1.sentence-2)
Little-endian is a format for storage of
binary data in which the least significant byte is placed first, with the rest
in ascending order[.](#1.sentence-3)
This subclause describes the endianness of the scalar types
of the execution environment[.](#1.sentence-4)
[🔗](#lib:endian)
`enum class endian {
little = see below,
big = see below,
native = see below
};
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L16044)
If all scalar types have size 1 byte, then all of endian::little,endian::big, and endian::native have the same value[.](#2.sentence-1)
Otherwise, endian::little is not equal to endian::big[.](#2.sentence-2)
If all scalar types are big-endian, endian::native is
equal to endian::big[.](#2.sentence-3)
If all scalar types are little-endian, endian::native is
equal to endian::little[.](#2.sentence-4)
Otherwise, endian::native is not equal
to either endian::big or endian::little[.](#2.sentence-5)