modf (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

3.10 / 1.00.00


This function will break the argument into an integral and a fractional part.

 

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 break into parts.

 

Output:

intpart : DOUBLE

The integral part of the value.

 

Returns: DOUBLE

The fraction part of the value.

 

Declaration:

FUNCTION modf : DOUBLE;
VAR_INPUT
  v       : DOUBLE;
  intpart : ACCESS DOUBLE;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
INCLUDE math.inc
 
PROGRAM test;
VAR
  a : DOUBLE;
  b : DOUBLE;
END_VAR;
 
a := modf(v := 10.0/8.0, intpart := b);
DebugFmt(message:=" 10/8 = " + doubleToStr(v := b) +" + " + doubleToStr(v := a));
 
END_PROGRAM;