ZK Core documentation/BitConverter

Offers functionality to work with binary data.

Instantiation
This type does not need to be instantiated.

Usage
Returns an  from two bytes making up an.

Parameters

 * a: the first byte of the value, must be in the range 0-255.
 * b: the second byte of the value, must be in the range 0-255.

Example
// the following bytes make up the 16-bit value 420 int number = BitConverter.ToInt16(0xA4, 0x01); Console.PrintF("%d", number); // output: 420

Usage
Returns an  from four bytes making up an.

Parameters

 * a: the first byte of the value, must be in the range 0-255.
 * b: the second byte of the value, must be in the range 0-255.
 * c: the third byte of the value, must be in the range 0-255.
 * d: the fourth byte of the value, must be in the range 0-255.

Example
// the following bytes make up the 32-bit value 420,000 int number = BitConverter.ToInt32(0xA0, 0x68, 0x06, 0x00); Console.PrintF("%d", number); // output: 420000

Usage
Returns a  from four bytes making up an IEEE 754 format.

Parameters

 * a: the first byte of the value, must be in the range 0-255.
 * b: the second byte of the value, must be in the range 0-255.
 * c: the third byte of the value, must be in the range 0-255.
 * d: the fourth byte of the value, must be in the range 0-255.

Example
// the following bytes make up the floating point value 4.20 double number = BitConverter.ToFloat32(0x66, 0x66, 0x86, 0x40); Console.PrintF("%f", number); // output: 4.200000

Usage
Returns four s representing the four bytes that make up.

Parameters

 * value: the  to retrieve the bytes for.

Example
int a, b, c, d; [a, b, c, d] = BitConverter.GetBytesInt32(420000); Console.PrintF("0x%X, 0x%X, 0x%X, 0x%X", a, b, c, d); // output: 0xA0, 0x68, 0x06, 0x00