Skip to content

Main content

Encoding: Pack Unsigned 24bit Word Tool

Pack one unsigned 24-bit integer into exactly three bytes under an explicit byte order.

Loading tool…

Description

Split the value into three base-256 octets; return most-significant first for big and reverse that order for little.

A fixed-width unsigned word has a bounded integer range and an explicit byte order. Reversing octet order changes representation while leaving the intended integer value unchanged.

Split the value into three base-256 octets; return most-significant first for big and reverse that order for little.

When to use this tool

Use Encoding: Pack Unsigned 24bit Word when packing one supplied unsigned word into its declared byte order.

How to use the tool and how it works

  1. Enter value, byteOrder. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read result. Expand result to inspect the returned fields.

Require whole value in [0,16777215] and byteOrder big or little. Split the value into three base-256 octets; return most-significant first for big and reverse that order for little.1

Input fieldMeaning and unitsAccepted input
valueValueRequired. Safe integer.
byteOrderByte OrderRequired. Text; one of "big", "little". Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.bytesBytesCalculated result member: array.
json
{
  "input": {
    "value": 1193046,
    "byteOrder": "big"
  },
  "output": {
    "result": {
      "bytes": [
        18,
        52,
        86
      ]
    }
  }
}

Limitations and assumptions

  • This packs one unsigned 24-bit word without framing, signed conversion or checksums. Byte order must match the consuming format.
  • Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Use the surrounding binary format for signedness, framing, alignment and integrity checks.

References

  1. Calculation and input contract: encode/pack-unsigned-24bit-word — tool.io

Similar or alternative tools