Skip to content

Main content

CBOR Small Integer Initial Octet Tool

Compute cbor small integer initial octet from explicit bounded inputs.

Loading tool…

Description

Return octet = value+(negative ? 32 : 0).

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 octet = value+(negative ? 32 : 0).

When to use this tool

Use CBOR Small Integer Initial Octet when checking one CBOR initial-byte, simple-value or negative-integer argument.

How to use the tool and how it works

  1. Enter value, negative. 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 octet. Use the output convention below.

Require whole value in [0,23]. Return octet = value+(negative ? 32 : 0). With negative false the semantic integer is value; with negative true it is -1-value.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
valueUnsigned CBOR argument 0-23; with negative true the represented integer is -1-value.Required. Safe integer; minimum 0; maximum 23.
negativeNegativeRequired. Boolean.
Output fieldInterpretationReturned shape
octetOctetRequired. Safe integer.
json
{
  "input": {
    "value": 5,
    "negative": false
  },
  "output": {
    "octet": 5
  }
}

Limitations and assumptions

  • value is CBOR's unsigned argument for the negative form, not the magnitude of the negative integer. This emits only the small-integer initial octet.
  • 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-small-integer-initial-octet — tool.io

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

Similar or alternative tools