Skip to main content

swap2(value)

Swaps the byte order of a 16-bit integer

Availability

Device + Agent

Parameters

Name Type Description
value Integer Any numerical value

Returns

Integer

Description

This function takes a 16-bit integer and swaps the byte order: bytes 0 and 1 become bytes 1 and 0. Because Squirrel integers are 32 bits long, swap2() ignores the upper two bytes of a Squirrel integer passed to it and zeros these bits in the returned value.

Do not confuse this function with the blob library’s blob.swap2() method, which works on a target blob object not an integer parameter.