FIX16Add

This function adds two signed 16-bit fixed-point numbers. The numbers do not have to have the same resolution (number of decimal places). The resolution of the number with the higher number of decimal places is reduced before the addition, i.e. the decimal places of the number with the higher resolution are truncated. The result of the addition is a signed 16-bit fixed-point number.
VAR_INPUT
VAR_INPUT
augend : T_FIX16;
addend : T_FIX16;
END_VAR
augend: The first summand.
addend: The second summand.
Example:
PROGRAM FIXADD
VAR
a, b : T_FIX16;
result : LREAL;
END_VAR
a := LREAL_TO_FIX16( 0.5, 8 );
b := LREAL_TO_FIX16( -0.25, 8 );
result := FIX16_TO_LREAL( FIX16Add( a, b ) ); (* The result is: 0.25 *)
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.10.0 Build >= 1326 | PC or CX (x86, ARM) | TcUtilities.Lib |