StringFromReal() Function
- Last UpdatedFeb 21, 2017
- 1 minute read
In a script, you can convert an real value to a string value by using the StringFromReal() function.
You can also specify to:
-
Round the value to a specified precision.
-
Pass the value in exponential notation.
This can be used, for example, to show text together with real values or for showing real numbers with exponential notation.
Syntax
result = StringFromReal (number, precision, type)
Parameters
number
A literal value, analog tagname, or numeric expression.
precision
Specifies how many decimal places are to be used. A literal integer value, integer tagname, or integer expression.
type
Specifies if the exponential notation is to be used. A literal string, message tagname, or string expression.
"f" - Use floating point notation.
"e" - Use exponential notation with lowercase "e".
"E" - Use exponential notation with uppercase "E".
Example(s)
StringFromReal(263.355, 2,"f") returns "263.36".
StringFromReal(263.355, 2,"e") returns "2.63e2".
StringFromReal(263.55, 3,"E") returns "2.636E2".
StringFromReal(0.5723, 2,"E") returns "5.72E-1".