Skip to content

Commit 56a8c7d

Browse files
authored
Merge pull request #290 from keichi/claude/doc-endianness-bit-order
Document that endianness affects bit field extraction order
2 parents bc75a66 + 8af5ddf commit 56a8c7d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ const parser = new Parser()
348348
.int32("c");
349349
```
350350

351+
This setting also affects the bit extraction order of
352+
[bit field](#bit1-32name-options) methods (`bit1` to `bit32`). In big-endian
353+
mode, bit fields are extracted from MSB to LSB.
354+
In little-endian mode, bit fields are extracted from LSB to MSB.
355+
If you need big-endian bit ordering while using little-endian
356+
byte ordering, you can parse bit fields in a separate `Parser` with
357+
`.endianness("big")` and embed it using `.nest()`.
358+
351359
### namely(alias)
352360
Set an alias to this parser, so that it can be referred to by name in methods
353361
like `.array`, `.nest` and `.choice`, without the requirement to have an

0 commit comments

Comments
 (0)