From 75bc39cd0c168914d3d25637a8f920f4c0848ae5 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Mon, 27 Jan 2014 13:11:25 +0000 Subject: [PATCH 01/20] Fix typo of missing end of box --- spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index 9f6af37e..74271b85 100644 --- a/spec.md +++ b/spec.md @@ -211,7 +211,7 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. uint 32 stores a 32-bit big-endian unsigned integer +--------+--------+--------+--------+--------+ - | 0xce |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ + | 0xce |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+--------+--------+ uint 64 stores a 64-bit big-endian unsigned integer @@ -246,7 +246,7 @@ Float format family stores an floating point number in 5 bytes or 9 bytes. float 32 stores a floating point number in IEEE 754 single precision floating point number format: +--------+--------+--------+--------+--------+ - | 0xca |XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX + | 0xca |XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX| +--------+--------+--------+--------+--------+ float 64 stores a floating point number in IEEE 754 double precision floating point number format: From 58f4431f3c387486e5d3e1de8578c4376403ca99 Mon Sep 17 00:00:00 2001 From: Stefan Friesel Date: Fri, 25 Jul 2014 14:58:40 +0200 Subject: [PATCH 02/20] Fix typos --- spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index 0523896a..c4ee3a16 100644 --- a/spec.md +++ b/spec.md @@ -18,7 +18,7 @@ Deserialization is conversion from MessagePack formats into application objects --> MessagePack type system --> Application objects -This document describes the MessagePack type system, MesagePack formats and conversion of them. +This document describes the MessagePack type system, MessagePack formats and conversion of them. ## Table of contents @@ -242,7 +242,7 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. ### float format family -Float format family stores an floating point number in 5 bytes or 9 bytes. +Float format family stores a floating point number in 5 bytes or 9 bytes. float 32 stores a floating point number in IEEE 754 single precision floating point number format: +--------+--------+--------+--------+--------+ From 2fb4eaa9688888b74bdabb2222f0e0f42712b6b1 Mon Sep 17 00:00:00 2001 From: Yuichi TANIKAWA Date: Tue, 12 Aug 2014 12:44:46 +0900 Subject: [PATCH 03/20] Fix a typo --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index c4ee3a16..ed1ed9aa 100644 --- a/spec.md +++ b/spec.md @@ -453,7 +453,7 @@ If an object can be represented in multiple possible output formats, serializers ## Deserialization: format to type conversion -MessagePack deserializers convert convert MessagePack formats into types as following: +MessagePack deserializers convert MessagePack formats into types as following: From c63d18164aaeefe7e169eb30c47c54c1dd0e44b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Sat, 13 Sep 2014 04:09:58 +0200 Subject: [PATCH 04/20] Fix mathematical range: [-1, -128] -> [-128, -1] The range `[-1, -128]` in the mathematical definition is actually empty. This PR exchanges the lower and upper bound: `[-128, -1]`. --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index ed1ed9aa..df027edc 100644 --- a/spec.md +++ b/spec.md @@ -85,7 +85,7 @@ Applications can assign `0` to `127` to store application-specific type informat MessagePack reserves `-1` to `-128` for future extension to add predefined types which will be described in separated documents. [0, 127]: application-specific types - [-1, -128]: reserved for predefined types + [-128, -1]: reserved for predefined types From 4a1784f14028804c0248361a86d518893676d363 Mon Sep 17 00:00:00 2001 From: wssbck Date: Tue, 18 Nov 2014 09:19:43 +0100 Subject: [PATCH 05/20] Update spec.md Typo fix. --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index ed1ed9aa..2489c980 100644 --- a/spec.md +++ b/spec.md @@ -263,7 +263,7 @@ Float format family stores a floating point number in 5 bytes or 9 bytes. ### str format family -Str format family stores an byte array in 1, 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. +Str format family stores a byte array in 1, 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. fixstr stores a byte array whose length is upto 31 bytes: +--------+========+ From 3b5b7b25033da9b28cea2a2213103a7e321507dc Mon Sep 17 00:00:00 2001 From: "TAGOMORI \"moris\" Satoshi" Date: Fri, 12 Jun 2015 18:25:28 +0900 Subject: [PATCH 06/20] Solve confusing naming about Extension or Extended --- spec.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/spec.md b/spec.md index 5780e274..0ab15654 100644 --- a/spec.md +++ b/spec.md @@ -58,9 +58,7 @@ This document describes the MessagePack type system, MessagePack formats and con * **Binary** extending Raw type represents a byte array * **Array** represents a sequence of objects * **Map** represents key-value pairs of objects - * **Extended** implements Extension interface: represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications -* Interfaces - * **Extension** represents a tuple of an integer and a byte array where the integer represents type information and the byte array represents data. The format of the data is defined by concrete types + * **Extension** represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications ### Limitation @@ -77,8 +75,8 @@ This document describes the MessagePack type system, MessagePack formats and con ### Extension type -MessagePack allows applications to define application-specific types using the Extended type. -Extended type consists of an integer and a byte array where the integer represents a kind of types and the byte array represents data. +MessagePack allows applications to define application-specific types using the Extension type. +Extension type consists of an integer and a byte array where the integer represents a kind of types and the byte array represents data. Applications can assign `0` to `127` to store application-specific type information. @@ -444,7 +442,7 @@ MessagePack serializers convert MessagePack types into formats as following: - +
source formatsoutput type
Binarybin format family (bin 8/16/32)
Arrayarray format family (fixarray or array 16/32)
Mapmap format family (fixmap or map 16/32)
Extendedext format family (fixext or ext 8/16/32)
Extensionext format family (fixext or ext 8/16/32)
If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes. @@ -465,7 +463,7 @@ MessagePack deserializers convert MessagePack formats into types as following: bin 8/16/32Binary fixarray and array 16/32Array fixmap map 16/32Map - fixext and ext 8/16/32Extended + fixext and ext 8/16/32Extension From 38f01c2564d8908278c26a03ea392db52b1825d0 Mon Sep 17 00:00:00 2001 From: Sadayuki Furuhashi Date: Mon, 15 Jun 2015 11:43:10 +0900 Subject: [PATCH 07/20] Make definition of Float type clear MessagePack type system has not defined error margin of Float type. A clear thing is that the type system does not distinguish single-precision from double-precision and double-precision is the finest precision. However, some applications need to be aware about precision especially when they compare a serialized floating point numbers with values comming from other data sources. This change makes it clear that MessagePack type system does not preserve size of error margin, and it uses IEEE 754 double-precision. --- spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.md b/spec.md index 0ab15654..843a4b26 100644 --- a/spec.md +++ b/spec.md @@ -52,7 +52,7 @@ This document describes the MessagePack type system, MessagePack formats and con * **Integer** represents an integer * **Nil** represents nil * **Boolean** represents true or false - * **Float** represents a floating point number + * **Float** represents a IEEE 754 double precision floating point number including NaN and Infinity * **Raw** * **String** extending Raw type represents a UTF-8 string * **Binary** extending Raw type represents a byte array @@ -64,7 +64,6 @@ This document describes the MessagePack type system, MessagePack formats and con ### Limitation * a value of an Integer object is limited from `-(2^63)` upto `(2^64)-1` -* a value of a Float object is IEEE 754 single or double precision floating-point number * maximum length of a Binary object is `(2^32)-1` * maximum byte size of a String object is `(2^32)-1` * String objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence @@ -253,7 +252,8 @@ Float format family stores a floating point number in 5 bytes or 9 bytes. +--------+--------+--------+--------+--------+--------+--------+--------+--------+ where - * XXXXXXXX_XXXXXXXX_XXXXXXXX_XXXXXXXX is a big-endian IEEE 754 single precision floating point number + * XXXXXXXX_XXXXXXXX_XXXXXXXX_XXXXXXXX is a big-endian IEEE 754 single precision floating point number. + Extension of precision from single-precision to double-precision does not lose precision. * YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY is a big-endian IEEE 754 double precision floating point number From 65c12af8d2a7a26b16fb95d4cc7bdb836588a8be Mon Sep 17 00:00:00 2001 From: Sadayuki Furuhashi Date: Tue, 22 Dec 2015 13:14:23 +0900 Subject: [PATCH 08/20] Proposal for timestamp type --- spec.md | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/spec.md b/spec.md index 843a4b26..b380bd72 100644 --- a/spec.md +++ b/spec.md @@ -25,7 +25,7 @@ This document describes the MessagePack type system, MessagePack formats and con * MessagePack specification * [Type system](#types) * [Limitation](#types-limitation) - * [Extension type](#types-extension-type) + * [Extension types](#types-extension-types) * [Formats](#formats) * [Overview](#formats-overview) * [Notation in diagrams](#formats-notation) @@ -38,6 +38,7 @@ This document describes the MessagePack type system, MessagePack formats and con * [array format family](#formats-array) * [map format family](#formats-map) * [ext format family](#formats-ext) + * [Timestamp extension type](#formats-timestamp) * [Serialization: type to format conversion](#serialization) * [Deserialization: format to type conversion](#deserialization) * [Future discussion](#future) @@ -58,7 +59,8 @@ This document describes the MessagePack type system, MessagePack formats and con * **Binary** extending Raw type represents a byte array * **Array** represents a sequence of objects * **Map** represents key-value pairs of objects - * **Extension** represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications + * **Extension** represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications or MessagePack specification + * **Timestamp** represents an instantaneous point on the time-line in the world that is independent from time zones or calendars. Maximum precision is nanoseconds. ### Limitation @@ -71,19 +73,27 @@ This document describes the MessagePack type system, MessagePack formats and con * maximum number of elements of an Array object is `(2^32)-1` * maximum number of key-value associations of a Map object is `(2^32)-1` - -### Extension type + +### Extension types MessagePack allows applications to define application-specific types using the Extension type. Extension type consists of an integer and a byte array where the integer represents a kind of types and the byte array represents data. -Applications can assign `0` to `127` to store application-specific type information. +Applications can assign `0` to `127` to store application-specific type information. An example usage is that application defines `type = 0` as the application's unique type system, and stores name of a type and values of the type at the payload. -MessagePack reserves `-1` to `-128` for future extension to add predefined types which will be described in separated documents. +MessagePack reserves `-1` to `-128` for future extension to add predefined types. These types will be added to exchange more types without using pre-shared statically-typed schema across different programming environments. [0, 127]: application-specific types [-1, -128]: reserved for predefined types +Because extension types are intended to be added, old applications may not implement all of them. However, they can still handle such type as one of Extension types. Therefore, applications can decide whether they reject unknown Extension types, accept as opaque data, or transfer to another application without touching payload of them. + +Here is the list of predefined extension types. Formats of the types are defined at [Formats](#formats-timestamp) section. + + + + +
NameType
Timestamp-1
## Formats @@ -427,6 +437,83 @@ Ext format family stores a tuple of an integer and a byte array. * type < 0 is reserved for future extension including 2-byte type information + +### Timestamp extension type + +Timestamp extension type is assigned to extension type `-1`. It defines 3 formats: 32-bit format, 64-bit format, and 96-bit format. + + timestamp 32 stores the number of seconds that have elapsed since 1970-01-01 00:00:00 UTC + in an 32-bit unsigned integer: + +--------+--------+--------+--------+--------+--------+ + | 0xd6 | -1 | seconds in 32-bit unsigned int | + +--------+--------+--------+--------+--------+--------+ + + timestamp 64 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC + in 2 32-bit unsigned integers: + +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ + | 0xd7 | -1 |nanoseconds in 30-bit unsigned int| seconds in 34-bit unsigned int | + +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ + + timestamp 96 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC + in 64-bit signed integer and 32-bit unsigned integer: + +--------+--------+--------+--------+--------+--------+--------+ + | 0xc7 | 12 | -1 |nanoseconds in 32-bit unsigned int | + +--------+--------+--------+--------+--------+--------+--------+ + +--------+--------+--------+--------+--------+--------+--------+--------+ + seconds in 64-bit signed int | + +--------+--------+--------+--------+--------+--------+--------+--------+ + +* Timestamp 32 format can represent a timestamp in [1970-01-01 00:00:00 UTC, 2106-02-07 06:28:16 UTC) range. Nanoseconds part is 0. +* Timestamp 64 format can represent a timestamp in [1970-01-01 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC) range. +* Timestamp 96 format can represent a timestamp in [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16.000000000 UTC) range. +* In timestamp 64 and timestamp 96 formats, nanoseconds must not be larger than 999999999. + +Pseudo code for serialization: + + struct timespec { + long tv_sec; // seconds + long tv_nsec; // nanoseconds + } time; + if ((time.tv_sec >> 34) == 0) { + uint64_t data64 = (time.tv_nsec << 34) | time.tv_sec; + if (data & 0xffffffff00000000L == 0) { + // timestamp 32 + uint32_t data32 = data64; + serialize(0xd6, -1, data32) + } + else { + // timestamp 64 + serialize(0xd7, -1, data64) + } + } + else { + // timestamp 96 + serialize(0xc7, 12, -1, time.tv_nsec, time.tv_sec) + } + +Pseudo code for deserialization: + + ExtensionValue value = deserialize_ext_type(); + struct timespec result; + switch(value.length) { + case 4: + uint32_t data32 = value.payload; + result.tv_nsec = 0; + result.tv_sec = data32; + case 8: + uint64_t data64 = value.payload; + result.tv_nsec = data64 >> 34; + result.tv_sec = data64 & 0x00000003ffffffffL; + case 12: + uint32_t data32 = value.payload; + uint64_t data64 = value.payload + 4; + result.tv_nsec = data32; + result.tv_sec = data64; + default: + // error + } + + ## Serialization: type to format conversion From fcfc08a55673d44f6da3a87e041ca6a2d14e67de Mon Sep 17 00:00:00 2001 From: Sadayuki Furuhashi Date: Mon, 24 Apr 2017 19:14:11 -0700 Subject: [PATCH 09/20] fixed typo in timestamp type --- spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index b380bd72..51830962 100644 --- a/spec.md +++ b/spec.md @@ -449,9 +449,9 @@ Timestamp extension type is assigned to extension type `-1`. It defines 3 format +--------+--------+--------+--------+--------+--------+ timestamp 64 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC - in 2 32-bit unsigned integers: + in 32-bit unsigned integers: +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ - | 0xd7 | -1 |nanoseconds in 30-bit unsigned int| seconds in 34-bit unsigned int | + | 0xd7 | -1 |nanoseconds in 30-bit unsigned int | seconds in 34-bit unsigned int | +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ timestamp 96 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC From f6179752d3d34b6c222370924a8fb9762a49822d Mon Sep 17 00:00:00 2001 From: Sadayuki Furuhashi Date: Wed, 9 Aug 2017 22:39:32 -0700 Subject: [PATCH 10/20] fixed typo in timestamp pseudo code --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 51830962..ba062d6e 100644 --- a/spec.md +++ b/spec.md @@ -476,7 +476,7 @@ Pseudo code for serialization: } time; if ((time.tv_sec >> 34) == 0) { uint64_t data64 = (time.tv_nsec << 34) | time.tv_sec; - if (data & 0xffffffff00000000L == 0) { + if (data64 & 0xffffffff00000000L == 0) { // timestamp 32 uint32_t data32 = data64; serialize(0xd6, -1, data32) From b49cfd0d91db407ba8e588317c4e93f53cdfe8f0 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 18 Sep 2017 16:48:15 +0900 Subject: [PATCH 11/20] fix anchor names of index --- spec.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/spec.md b/spec.md index b1bfe6b0..46021667 100644 --- a/spec.md +++ b/spec.md @@ -23,28 +23,28 @@ This document describes the MessagePack type system, MessagePack formats and con ## Table of contents * MessagePack specification - * [Type system](#types) - * [Limitation](#types-limitation) - * [Extension types](#types-extension-types) + * [Type system](#type-system) + * [Limitation](#limitation) + * [Extension types](#extension-types) * [Formats](#formats) - * [Overview](#formats-overview) - * [Notation in diagrams](#formats-notation) - * [nil format family](#formats-nil) - * [bool format family](#formats-bool) - * [int format family](#formats-int) - * [float format family](#formats-float) - * [str format family](#formats-str) - * [bin format family](#formats-bin) - * [array format family](#formats-array) - * [map format family](#formats-map) - * [ext format family](#formats-ext) - * [Timestamp extension type](#formats-timestamp) - * [Serialization: type to format conversion](#serialization) - * [Deserialization: format to type conversion](#deserialization) - * [Future discussion](#future) - * [Profile](#future-profiles) - * [Implementation guidelines](#impl) - * [Upgrade MessagePack specification](#impl-upgrade) + * [Overview](#overview) + * [Notation in diagrams](#notation-in-diagrams) + * [nil format](#nil-format) + * [bool format family](#bool-format-family) + * [int format family](#int-format-family) + * [float format family](#float-format-family) + * [str format family](#str-format-family) + * [bin format family](#bin-format-family) + * [array format family](#array-format-family) + * [map format family](#map-format-family) + * [ext format family](#ext-format-family) + * [Timestamp extension type](#timestamp-extension-type) + * [Serialization: type to format conversion](#serialization-type-to-format-conversion) + * [Deserialization: format to type conversion](#deserialization-format-to-type-conversion) + * [Future discussion](#future-discussion) + * [Profile](#profile) + * [Implementation guidelines](#implementation-guidelines) + * [Upgrading MessagePack specification](#upgrading-messagepack-specification) ## Type system From 6b210da84e7e782e4ff76df2f66a43a5a2150044 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 18 Sep 2017 16:53:33 +0900 Subject: [PATCH 12/20] remove unused/invalid anchor links --- spec.md | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/spec.md b/spec.md index 46021667..837f487b 100644 --- a/spec.md +++ b/spec.md @@ -46,7 +46,6 @@ This document describes the MessagePack type system, MessagePack formats and con * [Implementation guidelines](#implementation-guidelines) * [Upgrading MessagePack specification](#upgrading-messagepack-specification) - ## Type system * Types @@ -62,7 +61,6 @@ This document describes the MessagePack type system, MessagePack formats and con * **Extension** represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications or MessagePack specification * **Timestamp** represents an instantaneous point on the time-line in the world that is independent from time zones or calendars. Maximum precision is nanoseconds. - ### Limitation * a value of an Integer object is limited from `-(2^63)` upto `(2^64)-1` @@ -73,7 +71,6 @@ This document describes the MessagePack type system, MessagePack formats and con * maximum number of elements of an Array object is `(2^32)-1` * maximum number of key-value associations of a Map object is `(2^32)-1` - ### Extension types MessagePack allows applications to define application-specific types using the Extension type. @@ -95,10 +92,8 @@ Here is the list of predefined extension types. Formats of the types are defined Timestamp-1 - ## Formats - ### Overview @@ -142,8 +137,6 @@ Here is the list of predefined extension types. Formats of the types are defined
negative fixint111xxxxx0xe0 - 0xff
- -
### Notation in diagrams one byte: @@ -163,7 +156,6 @@ Here is the list of predefined extension types. Formats of the types are defined `X`, `Y`, `Z` and `A` are the symbols that will be replaced by an actual bit. - ### nil format Nil format stores nil in 1 byte. @@ -173,7 +165,6 @@ Nil format stores nil in 1 byte. | 0xc0 | +--------+ - ### bool format family Bool format family stores false or true in 1 byte. @@ -188,7 +179,6 @@ Bool format family stores false or true in 1 byte. | 0xc3 | +--------+ - ### int format family Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. @@ -246,7 +236,6 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. | 0xd3 |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+--------+--------+--------+--------+--------+--------+ - ### float format family Float format family stores a floating point number in 5 bytes or 9 bytes. @@ -267,8 +256,6 @@ Float format family stores a floating point number in 5 bytes or 9 bytes. * YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY_YYYYYYYY is a big-endian IEEE 754 double precision floating point number - - ### str format family Str format family stores a byte array in 1, 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. @@ -300,7 +287,6 @@ Str format family stores a byte array in 1, 2, 3, or 5 bytes of extra bytes in a * AAAAAAAA_AAAAAAAA_AAAAAAAA_AAAAAAAA is a 32-bit big-endian unsigned integer which represents N * N is the length of data - ### bin format family Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes in addition to the size of the byte array. @@ -326,7 +312,6 @@ Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes in add * ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ is a 32-bit big-endian unsigned integer which represents N * N is the length of data - ### array format family Array format family stores a sequence of elements in 1, 3, or 5 bytes of extra bytes in addition to the elements. @@ -352,7 +337,6 @@ Array format family stores a sequence of elements in 1, 3, or 5 bytes of extra b * ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ is a 32-bit big-endian unsigned integer which represents N N is the size of a array - ### map format family Map format family stores a sequence of key-value pairs in 1, 3, or 5 bytes of extra bytes in addition to the key-value pairs. @@ -380,7 +364,6 @@ Map format family stores a sequence of key-value pairs in 1, 3, or 5 bytes of ex * odd elements in objects are keys of a map * the next element of a key is its associated value - ### ext format family Ext format family stores a tuple of an integer and a byte array. @@ -436,8 +419,6 @@ Ext format family stores a tuple of an integer and a byte array. * type is a signed 8-bit signed integer * type < 0 is reserved for future extension including 2-byte type information - - ### Timestamp extension type Timestamp extension type is assigned to extension type `-1`. It defines 3 formats: 32-bit format, 64-bit format, and 96-bit format. @@ -513,8 +494,6 @@ Pseudo code for deserialization: // error } - - ## Serialization: type to format conversion MessagePack serializers convert MessagePack types into formats as following: @@ -534,8 +513,6 @@ MessagePack serializers convert MessagePack types into formats as following: If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes. - - ## Deserialization: format to type conversion MessagePack deserializers convert MessagePack formats into types as following: @@ -553,20 +530,16 @@ MessagePack deserializers convert MessagePack formats into types as following: fixext and ext 8/16/32Extension - ## Future discussion - ### Profile Profile is an idea that Applications restrict the semantics of MessagePack while sharing the same syntax to adapt MessagePack for certain use cases. For example, applications may remove Binary type, restrict keys of map objects to be String type, and put some restrictions to make the semantics compatible with JSON. Applications which use schema may remove String and Binary types and deal with byte arrays as Raw type. Applications which use hash (digest) of serialized data may sort keys of maps to make the serialized data deterministic. - ## implementation guidelines - ### Upgrading MessagePack specification MessagePack specification is changed at this time. From 8db0b50c16c6991fc414be586cbeaa06f885ad47 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 18 Sep 2017 16:55:43 +0900 Subject: [PATCH 13/20] remove whitespaces (auto format via Atom md editor) --- spec.md | 62 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/spec.md b/spec.md index 837f487b..e99ad5b8 100644 --- a/spec.md +++ b/spec.md @@ -143,17 +143,17 @@ Here is the list of predefined extension types. Formats of the types are defined +--------+ | | +--------+ - + a variable number of bytes: +========+ | | +========+ - + variable number of objects stored in MessagePack format: +~~~~~~~~~~~~~~~~~+ | | +~~~~~~~~~~~~~~~~~+ - + `X`, `Y`, `Z` and `A` are the symbols that will be replaced by an actual bit. ### nil format @@ -173,7 +173,7 @@ Bool format family stores false or true in 1 byte. +--------+ | 0xc2 | +--------+ - + true: +--------+ | 0xc3 | @@ -187,12 +187,12 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. +--------+ |0XXXXXXX| +--------+ - + negative fixnum stores 5-bit negative integer +--------+ |111YYYYY| +--------+ - + * 0XXXXXXX is 8-bit unsigned integer * 111YYYYY is 8-bit signed integer @@ -200,17 +200,17 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. +--------+--------+ | 0xcc |ZZZZZZZZ| +--------+--------+ - + uint 16 stores a 16-bit big-endian unsigned integer +--------+--------+--------+ | 0xcd |ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+ - + uint 32 stores a 32-bit big-endian unsigned integer +--------+--------+--------+--------+--------+ | 0xce |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+--------+--------+ - + uint 64 stores a 64-bit big-endian unsigned integer +--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 0xcf |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| @@ -220,17 +220,17 @@ Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. +--------+--------+ | 0xd0 |ZZZZZZZZ| +--------+--------+ - + int 16 stores a 16-bit big-endian signed integer +--------+--------+--------+ | 0xd1 |ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+ - + int 32 stores a 32-bit big-endian signed integer +--------+--------+--------+--------+--------+ | 0xd2 |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| +--------+--------+--------+--------+--------+ - + int 64 stores a 64-bit big-endian signed integer +--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 0xd3 |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| @@ -244,12 +244,12 @@ Float format family stores a floating point number in 5 bytes or 9 bytes. +--------+--------+--------+--------+--------+ | 0xca |XXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX| +--------+--------+--------+--------+--------+ - + float 64 stores a floating point number in IEEE 754 double precision floating point number format: +--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 0xcb |YYYYYYYY|YYYYYYYY|YYYYYYYY|YYYYYYYY|YYYYYYYY|YYYYYYYY|YYYYYYYY|YYYYYYYY| +--------+--------+--------+--------+--------+--------+--------+--------+--------+ - + where * XXXXXXXX_XXXXXXXX_XXXXXXXX_XXXXXXXX is a big-endian IEEE 754 single precision floating point number. Extension of precision from single-precision to double-precision does not lose precision. @@ -264,17 +264,17 @@ Str format family stores a byte array in 1, 2, 3, or 5 bytes of extra bytes in a +--------+========+ |101XXXXX| data | +--------+========+ - + str 8 stores a byte array whose length is upto (2^8)-1 bytes: +--------+--------+========+ | 0xd9 |YYYYYYYY| data | +--------+--------+========+ - + str 16 stores a byte array whose length is upto (2^16)-1 bytes: +--------+--------+--------+========+ | 0xda |ZZZZZZZZ|ZZZZZZZZ| data | +--------+--------+--------+========+ - + str 32 stores a byte array whose length is upto (2^32)-1 bytes: +--------+--------+--------+--------+--------+========+ | 0xdb |AAAAAAAA|AAAAAAAA|AAAAAAAA|AAAAAAAA| data | @@ -295,12 +295,12 @@ Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes in add +--------+--------+========+ | 0xc4 |XXXXXXXX| data | +--------+--------+========+ - + bin 16 stores a byte array whose length is upto (2^16)-1 bytes: +--------+--------+--------+========+ | 0xc5 |YYYYYYYY|YYYYYYYY| data | +--------+--------+--------+========+ - + bin 32 stores a byte array whose length is upto (2^32)-1 bytes: +--------+--------+--------+--------+--------+========+ | 0xc6 |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| data | @@ -320,17 +320,17 @@ Array format family stores a sequence of elements in 1, 3, or 5 bytes of extra b +--------+~~~~~~~~~~~~~~~~~+ |1001XXXX| N objects | +--------+~~~~~~~~~~~~~~~~~+ - + array 16 stores an array whose length is upto (2^16)-1 elements: +--------+--------+--------+~~~~~~~~~~~~~~~~~+ | 0xdc |YYYYYYYY|YYYYYYYY| N objects | +--------+--------+--------+~~~~~~~~~~~~~~~~~+ - + array 32 stores an array whose length is upto (2^32)-1 elements: +--------+--------+--------+--------+--------+~~~~~~~~~~~~~~~~~+ | 0xdd |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| N objects | +--------+--------+--------+--------+--------+~~~~~~~~~~~~~~~~~+ - + where * XXXX is a 4-bit unsigned integer which represents N * YYYYYYYY_YYYYYYYY is a 16-bit big-endian unsigned integer which represents N @@ -345,17 +345,17 @@ Map format family stores a sequence of key-value pairs in 1, 3, or 5 bytes of ex +--------+~~~~~~~~~~~~~~~~~+ |1000XXXX| N*2 objects | +--------+~~~~~~~~~~~~~~~~~+ - + map 16 stores a map whose length is upto (2^16)-1 elements +--------+--------+--------+~~~~~~~~~~~~~~~~~+ | 0xde |YYYYYYYY|YYYYYYYY| N*2 objects | +--------+--------+--------+~~~~~~~~~~~~~~~~~+ - + map 32 stores a map whose length is upto (2^32)-1 elements +--------+--------+--------+--------+--------+~~~~~~~~~~~~~~~~~+ | 0xdf |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| N*2 objects | +--------+--------+--------+--------+--------+~~~~~~~~~~~~~~~~~+ - + where * XXXX is a 4-bit unsigned integer which represents N * YYYYYYYY_YYYYYYYY is a 16-bit big-endian unsigned integer which represents N @@ -372,22 +372,22 @@ Ext format family stores a tuple of an integer and a byte array. +--------+--------+--------+ | 0xd4 | type | data | +--------+--------+--------+ - + fixext 2 stores an integer and a byte array whose length is 2 bytes +--------+--------+--------+--------+ | 0xd5 | type | data | +--------+--------+--------+--------+ - + fixext 4 stores an integer and a byte array whose length is 4 bytes +--------+--------+--------+--------+--------+--------+ | 0xd6 | type | data | +--------+--------+--------+--------+--------+--------+ - + fixext 8 stores an integer and a byte array whose length is 8 bytes +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 0xd7 | type | data | +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ - + fixext 16 stores an integer and a byte array whose length is 16 bytes +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ | 0xd8 | type | data @@ -400,12 +400,12 @@ Ext format family stores a tuple of an integer and a byte array. +--------+--------+--------+========+ | 0xc7 |XXXXXXXX| type | data | +--------+--------+--------+========+ - + ext 16 stores an integer and a byte array whose length is upto (2^16)-1 bytes: +--------+--------+--------+--------+========+ | 0xc8 |YYYYYYYY|YYYYYYYY| type | data | +--------+--------+--------+--------+========+ - + ext 32 stores an integer and a byte array whose length is upto (2^32)-1 bytes: +--------+--------+--------+--------+--------+--------+========+ | 0xc9 |ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ|ZZZZZZZZ| type | data | From 4af418d2dc659affdff0b131373b52e95a73cadc Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 18 Sep 2017 16:56:41 +0900 Subject: [PATCH 14/20] fix capitalization --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index e99ad5b8..76076dd7 100644 --- a/spec.md +++ b/spec.md @@ -538,7 +538,7 @@ Profile is an idea that Applications restrict the semantics of MessagePack while For example, applications may remove Binary type, restrict keys of map objects to be String type, and put some restrictions to make the semantics compatible with JSON. Applications which use schema may remove String and Binary types and deal with byte arrays as Raw type. Applications which use hash (digest) of serialized data may sort keys of maps to make the serialized data deterministic. -## implementation guidelines +## Implementation guidelines ### Upgrading MessagePack specification From b006b32db4a85e9985eb92700750c1019b1ac7a2 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 18 Sep 2017 16:58:43 +0900 Subject: [PATCH 15/20] update "Last modified" with last modified date of spec --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 76076dd7..abab8734 100644 --- a/spec.md +++ b/spec.md @@ -553,5 +553,5 @@ Here is a guideline to upgrade existent MessagePack implementations: ___ MessagePack specification - Last modified at 2013-04-21 21:52:33 -0700 + Last modified at 2017-08-09 22:42:07 -0700 Sadayuki Furuhashi © 2013-04-21 21:52:33 -0700 From cdde420a9c0d1dee2645b67762a3377281daf7e2 Mon Sep 17 00:00:00 2001 From: Gabe Appleton Date: Wed, 25 Jul 2018 20:54:58 -0700 Subject: [PATCH 16/20] Change from HTML tables to Markdown tables This allows you to generate an accurate PDF from pandoc --- spec.md | 132 +++++++++++++++++++++++++++----------------------------- 1 file changed, 64 insertions(+), 68 deletions(-) diff --git a/spec.md b/spec.md index abab8734..75507284 100644 --- a/spec.md +++ b/spec.md @@ -87,55 +87,53 @@ Because extension types are intended to be added, old applications may not imple Here is the list of predefined extension types. Formats of the types are defined at [Formats](#formats-timestamp) section. - - - -
NameType
Timestamp-1
+Name | Type +--------- | ---- +Timestamp | -1 ## Formats ### Overview - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
format namefirst byte (in binary)first byte (in hex)
positive fixint0xxxxxxx0x00 - 0x7f
fixmap1000xxxx0x80 - 0x8f
fixarray1001xxxx0x90 - 0x9f
fixstr101xxxxx0xa0 - 0xbf
nil110000000xc0
(never used)110000010xc1
false110000100xc2
true110000110xc3
bin 8110001000xc4
bin 16110001010xc5
bin 32110001100xc6
ext 8110001110xc7
ext 16110010000xc8
ext 32110010010xc9
float 32110010100xca
float 64110010110xcb
uint 8110011000xcc
uint 16110011010xcd
uint 32110011100xce
uint 64110011110xcf
int 8110100000xd0
int 16110100010xd1
int 32110100100xd2
int 64110100110xd3
fixext 1110101000xd4
fixext 2110101010xd5
fixext 4110101100xd6
fixext 8110101110xd7
fixext 16110110000xd8
str 8110110010xd9
str 16110110100xda
str 32110110110xdb
array 16110111000xdc
array 32110111010xdd
map 16110111100xde
map 32110111110xdf
negative fixint111xxxxx0xe0 - 0xff
+format name | first byte (in binary) | first byte (in hex) +--------------- | ---------------------- | ------------------- +positive fixint | 0xxxxxxx | 0x00 - 0x7f +fixmap | 1000xxxx | 0x80 - 0x8f +fixarray | 1001xxxx | 0x90 - 0x9f +fixstr | 101xxxxx | 0xa0 - 0xbf +nil | 11000000 | 0xc0 +(never used) | 11000001 | 0xc1 +false | 11000010 | 0xc2 +true | 11000011 | 0xc3 +bin 8 | 11000100 | 0xc4 +bin 16 | 11000101 | 0xc5 +bin 32 | 11000110 | 0xc6 +ext 8 | 11000111 | 0xc7 +ext 16 | 11001000 | 0xc8 +ext 32 | 11001001 | 0xc9 +float 32 | 11001010 | 0xca +float 64 | 11001011 | 0xcb +uint 8 | 11001100 | 0xcc +uint 16 | 11001101 | 0xcd +uint 32 | 11001110 | 0xce +uint 64 | 11001111 | 0xcf +int 8 | 11010000 | 0xd0 +int 16 | 11010001 | 0xd1 +int 32 | 11010010 | 0xd2 +int 64 | 11010011 | 0xd3 +fixext 1 | 11010100 | 0xd4 +fixext 2 | 11010101 | 0xd5 +fixext 4 | 11010110 | 0xd6 +fixext 8 | 11010111 | 0xd7 +fixext 16 | 11011000 | 0xd8 +str 8 | 11011001 | 0xd9 +str 16 | 11011010 | 0xda +str 32 | 11011011 | 0xdb +array 16 | 11011100 | 0xdc +array 32 | 11011101 | 0xdd +map 16 | 11011110 | 0xde +map 32 | 11011111 | 0xdf +negative fixint | 111xxxxx | 0xe0 - 0xff ### Notation in diagrams @@ -498,18 +496,17 @@ Pseudo code for deserialization: MessagePack serializers convert MessagePack types into formats as following: - - - - - - - - - - - -
source typesoutput format
Integerint format family (positive fixint, negative fixint, int 8/16/32/64 or uint 8/16/32/64)
Nilnil
Booleanbool format family (false or true)
Floatfloat format family (float 32/64)
Stringstr format family (fixstr or str 8/16/32)
Binarybin format family (bin 8/16/32)
Arrayarray format family (fixarray or array 16/32)
Mapmap format family (fixmap or map 16/32)
Extensionext format family (fixext or ext 8/16/32)
+source types | output format +------------ | --------------------------------------------------------------------------------------- +Integer | int format family (positive fixint, negative fixint, int 8/16/32/64 or uint 8/16/32/64) +Nil | nil +Boolean | bool format family (false or true) +Float | float format family (float 32/64) +String | str format family (fixstr or str 8/16/32) +Binary | bin format family (bin 8/16/32) +Array | array format family (fixarray or array 16/32) +Map | map format family (fixmap or map 16/32) +Extension | ext format family (fixext or ext 8/16/32) If an object can be represented in multiple possible output formats, serializers SHOULD use the format which represents the data in the smallest number of bytes. @@ -517,18 +514,17 @@ If an object can be represented in multiple possible output formats, serializers MessagePack deserializers convert MessagePack formats into types as following: - - - - - - - - - - - -
source formatsoutput type
positive fixint, negative fixint, int 8/16/32/64 and uint 8/16/32/64Integer
nilNil
false and trueBoolean
float 32/64Float
fixstr and str 8/16/32String
bin 8/16/32Binary
fixarray and array 16/32Array
fixmap map 16/32Map
fixext and ext 8/16/32Extension
+source formats | output type +-------------------------------------------------------------------- | ----------- +positive fixint, negative fixint, int 8/16/32/64 and uint 8/16/32/64 | Integer +nil | Nil +false and true | Boolean +float 32/64 | Float +fixstr and str 8/16/32 | String +bin 8/16/32 | Binary +fixarray and array 16/32 | Array +fixmap map 16/32 | Map +fixext and ext 8/16/32 | Extension ## Future discussion From 3f0a9aae716596a86878c0d68dc0bd4256673202 Mon Sep 17 00:00:00 2001 From: Eric Cochran Date: Mon, 17 Sep 2018 12:11:40 -0700 Subject: [PATCH 17/20] Fix missing bullet point in array doc. --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 75507284..01b12acf 100644 --- a/spec.md +++ b/spec.md @@ -333,7 +333,7 @@ Array format family stores a sequence of elements in 1, 3, or 5 bytes of extra b * XXXX is a 4-bit unsigned integer which represents N * YYYYYYYY_YYYYYYYY is a 16-bit big-endian unsigned integer which represents N * ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ_ZZZZZZZZ is a 32-bit big-endian unsigned integer which represents N - N is the size of a array + * N is the size of an array ### map format family From 2f630d6606c105dcbcbf3bfbb0145d8009813a09 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Fri, 5 Apr 2019 09:42:55 +0200 Subject: [PATCH 18/20] Fix incorrectly specified range of 64bit timestamps The currently specified range [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16 UTC) implies a range of ~3.7e19 seconds; however, if have only 64bit to encode an amount of seconds you can only represent amounts up to 18446744073709551615 seconds (i.e. ~1.8e19). Consequently, the correct range when using a signed 64-bit integer to represent seconds is [-292277022657-01-27 08:29:52 UTC, 292277026596-12-04 15:30:08 UTC) --- spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.md b/spec.md index 01b12acf..4ca0ba85 100644 --- a/spec.md +++ b/spec.md @@ -444,7 +444,7 @@ Timestamp extension type is assigned to extension type `-1`. It defines 3 format * Timestamp 32 format can represent a timestamp in [1970-01-01 00:00:00 UTC, 2106-02-07 06:28:16 UTC) range. Nanoseconds part is 0. * Timestamp 64 format can represent a timestamp in [1970-01-01 00:00:00.000000000 UTC, 2514-05-30 01:53:04.000000000 UTC) range. -* Timestamp 96 format can represent a timestamp in [-584554047284-02-23 16:59:44 UTC, 584554051223-11-09 07:00:16.000000000 UTC) range. +* Timestamp 96 format can represent a timestamp in [-292277022657-01-27 08:29:52 UTC, 292277026596-12-04 15:30:08.000000000 UTC) range. * In timestamp 64 and timestamp 96 formats, nanoseconds must not be larger than 999999999. Pseudo code for serialization: From bafe44a435cef246887bebfe6ecd91595464c947 Mon Sep 17 00:00:00 2001 From: Louis Somers Date: Mon, 15 Mar 2021 22:42:07 +0100 Subject: [PATCH 19/20] Update spec.md --- spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec.md b/spec.md index 01b12acf..b6134799 100644 --- a/spec.md +++ b/spec.md @@ -429,9 +429,9 @@ Timestamp extension type is assigned to extension type `-1`. It defines 3 format timestamp 64 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC in 32-bit unsigned integers: - +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ - | 0xd7 | -1 |nanoseconds in 30-bit unsigned int | seconds in 34-bit unsigned int | - +--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+ + +--------+--------+--------+--------+--------+------|-+--------+--------+--------+--------+ + | 0xd7 | -1 | nanosec. in 30-bit unsigned int | seconds in 34-bit unsigned int | + +--------+--------+--------+--------+--------+------^-+--------+--------+--------+--------+ timestamp 96 stores the number of seconds and nanoseconds that have elapsed since 1970-01-01 00:00:00 UTC in 64-bit signed integer and 32-bit unsigned integer: From 9aa092d6ca81f12005bd7dcbeb6488ad319e5133 Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Wed, 28 Apr 2021 18:19:03 -0400 Subject: [PATCH 20/20] Correct "fixnum" to "fixint" in new spec (to match rest of document) It appears that the terminology was changed between the 2011 and 2013 versions, but that not all instances were corrected. Closes #170 --- spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec.md b/spec.md index eed22ecb..bd3cb51a 100644 --- a/spec.md +++ b/spec.md @@ -181,12 +181,12 @@ Bool format family stores false or true in 1 byte. Int format family stores an integer in 1, 2, 3, 5, or 9 bytes. - positive fixnum stores 7-bit positive integer + positive fixint stores 7-bit positive integer +--------+ |0XXXXXXX| +--------+ - negative fixnum stores 5-bit negative integer + negative fixint stores 5-bit negative integer +--------+ |111YYYYY| +--------+