4. Bit Syntax

4 Bit Syntax

4.1 Introduction

In Erlang, a Bin is used for constructing binaries and matching binary patterns. A Bin is written with the following syntax:

<<E1, E2, ... En>>

A Bin is a low-level sequence of bits or bytes. The purpose of a Bin is to enable construction of binaries:

Bin = <<E1, E2, ... En>>

All elements must be bound. Or match a binary:

<<E1, E2, ... En>> = Bin 

Here, Bin is bound and the elements are bound or unbound, as in any match.

Since Erlang R12B, a Bin does not need to consist of a whole number of bytes.

A bitstring is a sequence of zero or more bits, where the number of bits does not need to be divisible by 8. If the number of bits is divisible by 8, the bitstring is also a binary.

Each eleme