Click or drag to resize

SwapByte Function

X#
Exchange the right and left halves of a byte.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION SwapByte(
	bSwap AS BYTE
) AS BYTE
Request Example View Source

Parameters

bSwap
Type: Byte
The byte whose nibbles you want to swap.

Return Value

Type: Byte
The byte value with swapped nibbles.
Remarks
SwapByte() swaps the right nibble of a byte with the left nibble of a byte and returns the result. (A nibble is 4 bits, which is half of a byte.)
Examples
This example uses SwapByte() on the character "A".
The ASCII value of "A" is 65. Thus, its binary representation is 0100 0001. Swapping it gives 0001 0100.
Therefore, an ASCII value of 20 is returned.
X#
1? SwapByte(Asc("A"))
See Also