floatToStr (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

3.10 / 1.00.00


This function converts a FLOAT to a string.

 

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

 

Please note that when using the Floating-Point Math functions in X32 and NX32 compilation mode then math.inc must be explicitly included by the application.

When using the NX32L compilation mode, math.inc is included by default.

 

Input:

v : FLOAT

Value to convert.

 

Returns: STRING

A string representation the value of v with 7 significant digits.

 

Declaration:

FUNCTION floatToStr : STRING;
VAR_INPUT
   v : FLOAT;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
INCLUDE math.inc
 
PROGRAM test;
 
DebugMsg(message := " sin(270) = " + floatToStr(:= sin(:= degToRad(:= 270.0))));
DebugMsg(message := " asin(1) = " + floatToStr(:= radToDeg(:= asin(:= 1.0))));
 
END_PROGRAM;