Skip to content

Main content

CBOR Simple Value Initial Octet Tool

Encode one CBOR simple value, rejecting the reserved simple values 24..31.

Loading tool…

Description

Encode a CBOR simple-value code while rejecting reserved values 24 through 31.

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.

Encode a CBOR simple-value code while rejecting reserved values 24 through 31.

When to use this tool

Use CBOR Simple Value 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 simpleValue. 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 octets. Use the output convention below.

Require whole simpleValue in [0,255], rejecting 24-31. For values below 24 return [224+simpleValue]; otherwise return [248,simpleValue].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
simpleValueSimple ValueRequired. Safe integer; minimum 0; maximum 255.
Output fieldInterpretationReturned shape
octetsOctetsRequired. Array of safe integer; maximum items 256.
json
{
  "input": {
    "simpleValue": 21
  },
  "output": {
    "octets": [
      245
    ]
  }
}

Limitations and assumptions

  • This encodes a simple-value code, not floating-point numbers or the separate break marker. The tool does not assign application meaning to unassigned simple values.
  • 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-simple-value-initial-octet — tool.io

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

Similar or alternative tools