fabs(Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

3.10 / 1.00.00


This function will calculate the absolute value.

 

Note: This function works with DOUBLE, but can also work with FLOAT as described in the Floating-point math introductory section.

 

Input:

V : DOUBLE

Value to convert.

 

Returns: DOUBLE

The absolute value of V.

 

Declaration:

FUNCTION fabs : DOUBLE;
VAR_INPUT
v : DOUBLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
INCLUDE math.inc
 
PROGRAM test;
 
DebugFmt(message := " abs( -123) = \4", v4 := abs( v:= -123)));
DebugFmt(message := "fabs(-1.23) = " + doubleToStr(v:= fabs(v:=-1.23)));
 
END_PROGRAM;