Skip to main content
7

Floating-Point and Simple Values

0xe0 – 0xffRFC 8949

CBOR major type 7 encodes simple values (false=0xf4, true=0xf5, null=0xf6, undefined=0xf7) and IEEE 754 floating-point numbers (half=0xf9, single=0xfa, double=0xfb). The break code 0xff terminates indefinite-length structures.

Encoding

Initial byte: 0b111_XXXXX. Various additional info values for each sub-type.

Major type 7 is the most heterogeneous major type. It covers:

Simple values (additional info 0-23): values 0-19 unassigned, 20 = false, 21 = true, 22 = null, 23 = undefined. Additional info 24 with one-byte value allows simple values 32-255.

Floating-point: additional info 25 = half-precision (2 bytes), 26 = single-precision (4 bytes), 27 = double-precision (8 bytes). All IEEE 754.

Break code: 0xff (additional info 31) terminates indefinite-length arrays, maps, byte strings, and text strings.

Key values: 0xf4 = false 0xf5 = true 0xf6 = null 0xf7 = undefined (rarely used) 0xf9 = half-precision float (2-byte IEEE 754) 0xfa = single-precision float (4-byte IEEE 754) 0xfb = double-precision float (8-byte IEEE 754) 0xff = break

Examples

LabelHexValue
falsef4false
truef5true
nullf6null
1.1 (double)fb 3f f1 99 99 99 99 99 9a1.1 (double-precision)
0.0 (half)f9 00 000.0 (half-precision)
breakffbreak (indefinite-length terminator)

See Also