Tipos de datos

Previous  home  Next   

Tipo

Ancho en bytes

Descripción

UINT16

2

Byte0: low

Byte1: high

En un pequeño sistema endian, un valor de datos UINT16 puede copiarse directamente en el payload.

Ejemplo:

//encoding

uint16 value = 9873;

char payload[2];

uint16* p = reinterpret_cast<uint16*>( payload );

*p = value;

 

//decoding

value = *( reinterpret_cast<const uint16*>( payload ) );

INT32

4

Byte0: low

Byte3: high

En un pequeño sistema endian, un valor de datos INT32 puede copiarse directamente en el payload.

Ejemplo:

//encoding

int32 value = -3459873;

char payload[4];

int32* p = reinterpret_cast<int32*>( payload );

*p = value;

 

//decoding

value = *( reinterpret_cast<const int32*>( payload ) );

UINT32

4

Byte0: low

Byte3: high

En un pequeño sistema endian, un valor de datos UINT32 puede copiarse directamente en el payload.

Ejemplo:

//encoding

uint32 value = 3459873;

char payload[4];

uint32* p = reinterpret_cast<uint32*>( payload );

*p = value;

 

//decoding

value = *( reinterpret_cast<const uint32*>( payload ) );