str = FormatReal(val, nDec);
A user friendly format of the real value val with nDec decimals is returned.
str1 := FormatReal(Modelica.Constants.pi, 5);
str2 := FormatReal(1e25*Modelica.Constants.pi, 5);
str3 := FormatReal(1e2*Modelica.Constants.pi, 5);
str4 := FormatReal(1e-2*Modelica.Constants.pi, 5);
str5 := FormatReal(1e-3*Modelica.Constants.pi, 5);
-> str1 = " 3.14159 "
-> str2 = " 3.14159e+25 "
-> str3 = " 314.15927 "
-> str4 = " 0.03142 "
-> str5 = " 3.14159e-3 "
function FormatReal import Modelica.Utilities.Streams.*; import Modelica.Utilities.Strings.*; extends Modelica.Icons.Function; input Real val "Value to be formatted"; input Integer nDec(min = 1) "Number of decimals of val to be shown"; output String str "Formatted return string"; end FormatReal;