Repository navigation
Add int24, uint24, int48 and uint48 parsers - #350
Merged
Merged
Conversation
Add int24/int24le/int24be and uint24/uint24le/uint24be. The unsuffixed variants follow endianness(). They are also usable as array element and choice types and are accounted for in sizeOf().
48-bit values fit in a safe integer, so they are returned as number (matching Buffer#readIntBE/readUIntBE with byteLength 6) rather than bigint.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
int24/int24le/int24be,uint24/uint24le/uint24be, and the same set for 48 bits. The unsuffixed variants followendianness(), like the other integer primitives. The suffixed types also work asarray/choiceelement types and insizeOf().DataView has no 24- or 48-bit getters, so the generated code builds the value from narrower reads. 48-bit values fit in a safe integer, so they are returned as
number(same asBuffer#readIntBE(offset, 6)), notbigint. All primitive reads now go through a sharedreadPrimitive()helper instead of four copies of the same template.Tests use the big-endian data from the issue (
f959a61a57c80fd3004801a9→-435802,1726408). The other expected values come fromBuffer#readIntBE/readIntLE/readUIntBE/readUIntLEon the same data.Fixes #93