Skip to content

Endianness

Endianness refers to the order in which bytes of multi-byte values are stored in memory. There are two main types of endianness: big-endian and little-endian.

In a big-endian system, the most significant byte (MSB) of a word is stored at the smallest memory address, while the least significant byte (LSB) is stored at the largest memory address.

On the other hand, in a little-endian system, the least significant byte (LSB) is stored at the smallest memory address, and the most significant byte (MSB) is stored at the largest memory address.

The endianness of the underlying data can be specified when creating a buffer. The default is big-endian.

var buffer = new ReadableByteBuffer( source, Endianness.BigEndian );

When using Channels, you won’t create input pipeline buffers directly (they are created internally by the channel), so this behavior must be configured at the channel level.

services.AddChannels( channel =>
{
    // configure channel options
    channel.Configure( options =>
    {
        // this is the default
        options.BufferEndianness = Endianness.BigEndian;
    } );

} );