Skip to content

Binary record-layout guide

Binary Endianness and Record Layout Review: Preserve Bytes Before Values

The same bytes can decode into different values when byte order, width, alignment, or stride is wrong. Preserve the raw boundary and document a layout hypothesis before interpreting a packed export.

A binary layout review starts with bytes, not decoded values. Record the endianness marker, field widths, signedness, alignment, padding, record stride, header version, and byte range used for each observation. Compare a synthetic hex fixture against the written layout and keep unknown fields unknown. A plausible decoded number is not proof that the layout is correct or that the export is complete, accurate, permitted, or valuable. Source dates shown here are documentation retrieval dates, checked 22 October 2026; original publication dates are not established.

Updated

On this page

Preserve the byte boundary and header

Keep an immutable artifact id, byte length, capture boundary, and the exact offset range under review. A decoded preview is derived evidence and should never replace the raw byte boundary. Record magic bytes, version markers, declared record count if present, and whether the export was copied or transformed. If the first bytes are missing, state that the header and layout cannot be verified.

A binary file can contain a header, records, padding, variable-length regions, and a trailer. Do not assume every byte belongs to a fixed-width row. A file extension, a successful library open, or a plausible first value does not establish the record boundary. Keep unknown offsets as unknown until a format document or owner note supports them.

Preserve the byte boundary and header (table)
Layout fieldEvidenceStop when
byte orderdeclared endian marker or format ruleOrder inferred from a value
field widthbytes per fieldWidth differs across versions
signednesssigned, unsigned, float, or unknownNegative interpretation is guessed
alignmentpadding and alignment ruleNative alignment is assumed
record stridebytes from one record to nextVariable-length area is ignored
versionheader version and sourceVersion is inferred from filename

Separate byte order, width, and alignment

Byte order controls how multiple bytes form a scalar. Width controls how many bytes are consumed. Alignment and padding control where the next field starts. These are independent hypotheses: a four-byte little-endian integer followed by an eight-bit flag is not the same layout as a native-aligned struct with three padding bytes. Write field offsets and end offsets rather than listing only field names.

The Python Software Foundation, (opens in a new tab) documentation warns that native mode follows the platform and compiler and can include pad bytes, while external data exchange requires explicit ordering and padding. Use standard, explicitly documented layout rules for a review worksheet and record any implementation-specific assumption as a limitation.

Separate byte order, width, and alignment (table)
HypothesisExample recordReview question
little-endian uint32offset 0, width 4Does the format specify little endian?
big-endian uint32offset 0, width 4Would the header identify the order?
signed int8offset 4, width 1Is the sign part of the field type?
paddingoffset 5 to 7Is alignment documented or assumed?
fixed stridenext record at offset 8Do all records have equal width?
variable payloadlength plus bytesWhich field defines the extent?

Keep decoded values tied to offsets

A review record should contain raw offset, byte slice reference, proposed field, type, order, width, decoded value if verified, and confidence or unresolved status. This lets a second reviewer challenge the layout without receiving private payloads. A value should not be copied into a summary without its byte-range evidence.

Link to the text encoding and row guide when a binary field contains text, but do not collapse encoding into byte order. UTF-8 bytes, integer endianness, and record stride answer different questions. Keep the source format version and conversion tool or owner note alongside the layout.

Offset discipline

  • Record offsets from the start of the artifact, not from a rendered preview.
  • Keep field width and padding explicit for every record member.
  • Preserve a redacted byte-slice id instead of copying private bytes into prose.
  • Mark an inferred value as unverified until the layout source is identified.
  • Re-check the stride when a version, architecture, or optional field changes.

Use a short synthetic hex fixture

The fixture below makes byte order and padding visible with harmless values. It is a worksheet, not an executable parser. Write the expected offsets and decoded values beside the bytes, then change one assumption at a time. If two layout hypotheses both fit the fixture, add a discriminating byte pattern rather than choosing the more convenient result.

Do not use customer identifiers or real binary payloads in a public example. A synthetic header, one record, and a second record with a different sign or byte order are enough to test the contract. Keep raw values in a controlled artifact only when the owner-approved boundary permits it.

Use a short synthetic hex fixture (table)
Synthetic findingDispositionNext evidence
Declared order and offsets fit both recordscontinue conditionallyCheck header and version evidence
Value fits only under native alignmentholdFind external format layout
Stride skips an observed byteholdReconcile padding or optional field
Header is absentlayout unverifiedObtain format metadata
Decoded value lacks source offsetincompleteAttach byte-range evidence

Synthetic fixed-record layout

Use a short synthetic hex fixture code example, Plain text
bytes: 01 00 00 00 7f 00 | 02 00 00 00 80 00
layout: uint32le@0..3, int8@4, pad@5; stride=6
record0: count=1, flag=127 | record1: count=2, flag=-128
check: big-endian interpretation would produce different counts

Report layout uncertainty narrowly

Use language such as “little-endian hypothesis fits the synthetic fixture” or “record stride unavailable.” Do not say that a decoder succeeded, therefore every record is valid. Keep corruption, truncation, wrong version, wrong architecture, and wrong semantic field meaning as separate possible causes.

A binary layout can be mechanically reproducible while its values remain semantically unknown. Record units, scaling, coordinate systems, or code lists separately. If the source has no authoritative layout description, preserve the decoded result as a hypothesis and do not promote it to a measurement.

Report layout uncertainty narrowly (table)
FindingDispositionDo not infer
Explicit layout fits header and fixturebounded passAll records have the same meaning
Endianness marker missingholdPlatform native order is correct
Padding differs by versionversioned reviewValues are corrupt
Byte range truncatedincompleteThe last record is zero
Units or semantics unknownstructural onlyDecoded number is a metric

Close with a qualified preparation step

After byte boundary, layout hypothesis, version, offsets, and synthetic evidence are documented, keep the packet structural. Do not upload private binary payloads merely to test an endian question. Use the data provenance log for copies and transformations and a data card for scope.

For a supported non-health collection, with authority to describe the artifact and a controlled handling boundary, the qualified appraisal path may be a next preparation step. It does not decode bytes, certify a layout, create a quote, match a buyer, issue a legal opinion, or grant a license. A reproducible binary interpretation is not proof of rights or accuracy.

Takeaways

  • Preserve raw offsets and header evidence before decoding values.
  • Specify byte order, width, signedness, alignment, padding, and stride separately.
  • Tie every decoded field to a byte range and format version.
  • Use synthetic bytes to discriminate layout hypotheses.
  • Keep mechanical decoding separate from semantic, rights, and accuracy decisions.

Sources

  1. Python Software Foundation: struct: Interpret bytes as packed binary data (opens in a new tab)
  2. Apache Arrow: Arrow Columnar Format (opens in a new tab)

Use the appraisal path after the technical packet is organized.

It does not parse files, certify evidence, create a quote, match a buyer, issue a legal opinion, or grant a license.