Endian codec (version 1.0)#
Editor’s draft 26 July 2019
- Specification URI:
https://zarr-specs.readthedocs.io/en/latest/v3/codecs/endian/v1.0.html
- Corresponding ZEP:
- Issue tracking:
- Suggest an edit for this spec:
Copyright 2020-Present Zarr core development team. This work is licensed under a Creative Commons Attribution 3.0 Unported License.
Abstract#
Defines an array -> bytes
codec that encodes arrays of fixed-size numeric
data types as little endian or big endian in lexicographical order.
Status of this document#
ZEP0001 was accepted on May 15th, 2023 via zarr-developers/zarr-specs#227.
Document conventions#
Conformance requirements are expressed with a combination of descriptive assertions and [RFC2119] terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in [RFC2119]. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. Examples in this specification are introduced with the words “for example”.
Codec name#
The value of the name
member in the codec object MUST be endian
.
Configuration parameters#
- endian:
Required. A string equal to either
"big"
or"little"
.
Format and algorithm#
This is an array -> bytes
codec.
Each element of the array is encoded using the specified endian variant of its
binary representation listed below. Array elements are encoded in
lexicographical order. For example, with endian
specified as big
, the
int32
data type is encoded as a 4-byte big endian two’s complement integer,
and the complex128
data type is encoded as two consecutive 8-byte big endian
IEEE 754 binary64 values.
Identifier |
Binary representation |
---|---|
|
Single byte, with false encoded as |
|
1 byte two’s complement. Does not depend on |
|
2-byte two’s complement |
|
4-byte two’s complement |
|
8-byte two’s complement |
|
1 byte. Does not depend on |
|
2-byte |
|
4-byte |
|
8-byte |
|
2-byte IEEE 754 binary16 |
|
4-byte IEEE 754 binary32 |
|
8-byte IEEE 754 binary64 |
|
2 consecutive 4-byte IEEE 754 binary32 values (real component followed by imaginary component) |
|
2 consecutive 8-byte IEEE 754 binary64 values (real component followed by imaginary component) |
|
number of bits, which must be a multiple of 8, given by |
Note
To encode elements in a different order than lexicographical order (C order/row major), the transpose codec may be specified.
References#
- RFC2119(1,2)
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
Change log#
No changes yet.