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
this example converts several different variable types.
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 | |
![]() |
Index |
Range: 0-3 | |
![]() |
Return |
GetFloat
![]() |
GetFloat |
Gets a single 32-bit FLOAT value | |
![]() |
Return |
GetInt
![]() |
GetInt |
Gets a single 16-bit INT value Index is in little endian, 0 is the LSW and 1 is the MSW | |
![]() |
Index |
Range: 0-1 | |
![]() |
Return |
GetLong
![]() |
GetLong |
Gets a single 32-bit LONG value | |
![]() |
Return |
SetByte
![]() |
SetByte |
Sets a single 8-bit BYTE value Index is in little endian, 0 is the LSB and 3 is the MSB | |
![]() |
Index |
Range: 0-3 | |
![]() |
Value |
Range: 0-255 | |
![]() |
Return |
SetBytes
![]() |
SetBytes |
Allows all bytes to be set using a single macro | |
![]() |
Byte0 |
![]() |
Byte1 |
![]() |
Byte2 |
![]() |
Byte3 |
![]() |
Return |
SetFloat
![]() |
SetFloat |
Sets a single 32-bit FLOAT value | |
![]() |
Value |
Range: 0-4294967295 | |
![]() |
Return |
SetInt
![]() |
SetInt |
Sets a single 16-bit INT value. Index is in little endian, 0 is the LSW and 1 is the MSW | |
![]() |
Index |
Range: 0-1 | |
![]() |
Value |
Range: 0-65535 | |
![]() |
Return |
SetLong
![]() |
SetLong |
Sets a single 32-bit LONG value | |
![]() |
Value |
Range: 0-4294967295 | |
![]() |
Return |
Property reference
![]() |
Properties |
![]() |
Generate Code |