Skip to content

Main content

Encoding: CBOR Initial Byte Fields Tool

Pack a CBOR initial byte from explicitly supplied major type and nonreserved additional-information fields; excludes subsequent data and semantic indefinite-length validation.

Loading tool…

Description

Return initialByte = majorType*32+additionalInformation.

CBOR combines a three-bit major type with additional information in an initial byte. Negative integers use an unsigned argument related by -1-n, while simple values and break markers have distinct meanings.

Return initialByte = majorType*32+additionalInformation.

When to use this tool

Use Encoding: CBOR Initial Byte Fields when checking one CBOR initial-byte, simple-value or negative-integer argument.

How to use the tool and how it works

  1. Enter majorType, additionalInformation. 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 majorType in [0,7] and additionalInformation in [0,31], excluding reserved values 28-30. Return initialByte = majorType*32+additionalInformation.1

CBOR type and argument conventions determine the encoded value. Constructing one argument or initial byte does not validate a full item.2

Input fieldMeaning and unitsAccepted input
majorTypeMajor TypeRequired. Safe integer.
additionalInformationInitial-byte low field 0-27 or 31; complete type compatibility is not checked.Required. Safe integer.
Output fieldInterpretationReturned shape
resultObject containing the named calculated members below.Required. Object.
result.initialByteInitial ByteCalculated result member: number.
json
{
  "input": {
    "majorType": 5,
    "additionalInformation": 1
  },
  "output": {
    "result": {
      "initialByte": 161
    }
  }
}

Limitations and assumptions

  • This combines fields only. Additional-information value 31 is not valid for every major type, and required following bytes or complete item validity are not checked.
  • 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 a complete CBOR encoder or decoder to check type-specific validity, following arguments and complete item structure.

References

  1. Calculation and input contract: encode/cbor-initial-byte-fields — tool.io

  2. Concise Binary Object Representation: RFC 8949 — Internet Engineering Task Force

Similar or alternative tools