Component: Type Conversions (Calculation)
Author | Matrix TSL |
Version | 1.0 |
Category | Calculation |
Contents
Type Conversions component
Component to simplify the task of converting data into different bit type variables. Allows conversion between Bytes, Ints, Longs and Floats. Useful when you need to store Ints, Longs and Floats into Byte based memory. Uses a simple 32-bit C Union to overlay the following variable types into the same RAM space. Byte[4], Int[2], Long, Float
Component Source Code
Please click here to download the component source project: FC_Comp_Source_TypeConversions.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_TypeConversions.fcfx
Detailed description
The type conversion component overlays several variable types on top of each other using a C code union.
This allows for very efficient conversion between data types without resorting to costly mathematics or bit shifting operations.
Here is an overview of the variable overlay.
Examples
No additional examples
Macro reference
GetByte
GetByte | |
Gets a single 8-bit BYTE value. Index is in little endian, 0 is the LSB and 3 is the MSB | |
- BYTE | Index |
Range: 0-3 | |
- BYTE | Return |
GetFloat
GetFloat | |
Gets a single 32-bit FLOAT value | |
- FLOAT | Return |
GetInt
GetInt | |
Gets a single 16-bit INT value Index is in little endian, 0 is the LSW and 1 is the MSW | |
- BYTE | Index |
Range: 0-1 | |
- UINT | Return |
GetLong
GetLong | |
Gets a single 32-bit LONG value | |
- ULONG | Return |
SetByte
SetByte | |
Sets a single 8-bit BYTE value Index is in little endian, 0 is the LSB and 3 is the MSB | |
- BYTE | Index |
Range: 0-3 | |
- BYTE | Value |
Range: 0-255 | |
- VOID | Return |
SetBytes
SetBytes | |
Allows all bytes to be set using a single macro | |
- BYTE | Byte0 |
- BYTE | Byte1 |
- BYTE | Byte2 |
- BYTE | Byte3 |
- VOID | Return |
SetFloat
SetFloat | |
Sets a single 32-bit FLOAT value | |
- FLOAT | Value |
Range: 0-4294967295 | |
- VOID | Return |
SetInt
SetInt | |
Sets a single 16-bit INT value. Index is in little endian, 0 is the LSW and 1 is the MSW | |
- BYTE | Index |
Range: 0-1 | |
- UINT | Value |
Range: 0-65535 | |
- VOID | Return |
SetLong
SetLong | |
Sets a single 32-bit LONG value | |
- ULONG | Value |
Range: 0-4294967295 | |
- VOID | Return |
Property reference
Properties | |
Generate Code | |