/ lang / datarep
Binary Data Representation
The READ and WRITE instructions allow to read and write binary representation of Gambas datatypes values.

Datatype | Size | Representation
--- | --- | ---
Boolean | 1 byte | `0` for FALSE, `255` for TRUE.
Byte | 1 byte | The data value in binary.
Short | 2 bytes | The data value in binary.
Integer | 4 bytes | The data value in binary.
Long | 8 bytes | The data value in binary.
Single | 4 bytes | The data value in binary.
Float | 8 bytes | The data value in binary.
Date | 8 bytes | The date and time as two four-bytes integers.
String | Variable | If you do not specified the string length, the string length is written just before the string data: One byte is written if the string length is lower or equal than 127 characters. Two bytes are written if the string length is between 128 and 16383 characters. Four bytes are written if the string length is between 16384 and 1073741824 characters. Longer strings cannot be written at the moment.
NULL | 1 byte | Null values and null strings are written as a single `0` byte.
Variant | Variable | When writing a variant value, a byte indicating the value datatype is written before. The value itself is written according to this table.

The endianness of the binary data is the endianness of the stream.

### See also

READ WRITE ByteOrder