Float
MessagePack float formats encode IEEE 754 floating-point numbers. float 32 (0xca) uses 4 bytes single-precision. float 64 (0xcb) uses 8 bytes double-precision. MessagePack has no half-precision format unlike CBOR.
Description
MessagePack supports two floating-point formats: 0xca = float 32: 1 prefix byte + 4 bytes IEEE 754 single-precision, big-endian 0xcb = float 64: 1 prefix byte + 8 bytes IEEE 754 double-precision, big-endian
Unlike integers, there is no 'fixfloat' – even 0.0 requires 5 bytes (0xca + 4 bytes). The spec mandates big-endian byte order for all multi-byte numeric values except the immediate-value fixint range.
Format Variants
| Name | First Byte | Range | Description |
|---|---|---|---|
| float 32 | 0xca | IEEE 754 single | 1 prefix byte + 4 bytes big-endian single-precision float. |
| float 64 | 0xcb | IEEE 754 double | 1 prefix byte + 8 bytes big-endian double-precision float. |
Examples
| Label | Hex | Value |
|---|---|---|
| 1.0 (float32) | ca 3f 80 00 00 | 1.0 (single-precision) |
| 1.0 (float64) | cb 3f f0 00 00 00 00 00 00 | 1.0 (double-precision) |
| 3.14 (float64) | cb 40 09 1e b8 51 eb 85 1f | 3.14 (approximate) |