Skip to content

Main content

Encoding: Packed BCD Byte Digits Tool

Pack exactly two explicit decimal digits into one packed-BCD octet, without a sign nibble or text encoding.

Loading tool…

Description

Return byte = 16*tens+units, putting the decimal tens digit in the high nibble.

Packed binary-coded decimal assigns one decimal digit to each four-bit nibble and may reserve a trailing nibble for a sign. Sign conventions vary by format, so a digit pair and a signed decimal record are different encodings.

Return byte = 16*tens+units, putting the decimal tens digit in the high nibble.

When to use this tool

Use Encoding: Packed BCD Byte Digits when inspecting one packed-decimal digit or declared sign-nibble convention.

How to use the tool and how it works

  1. Enter tens, units. 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 tens and units each in [0,9]. Return byte = 16*tens+units, putting the decimal tens digit in the high nibble.1

Input fieldMeaning and unitsAccepted input
tensTensRequired. Safe integer.
unitsUnitsRequired. Safe integer.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.byteByteCalculated result member: number.
json
{
  "input": {
    "tens": 4,
    "units": 2
  },
  "output": {
    "result": {
      "byte": 66
    }
  }
}

Limitations and assumptions

  • This is one unsigned packed BCD digit pair. It does not add a sign nibble, validate a larger record or encode binary decimal values through ordinary integer conversion.
  • 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 complete record format to establish digit count, sign policy, byte layout and compatibility.

References

  1. Calculation and input contract: encode/packed-bcd-byte-digits — tool.io

Similar or alternative tools