functionFormatReal

A user friendly format of the real value val with nDec decimals is returned.

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

str = FormatReal(val, nDec);

Description

A user friendly format of the real value val with nDec decimals is returned.

Example

  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  "              

Inputs

TypeNameDefaultDescription
RealvalValue to be formatted
IntegernDecNumber of decimals of val to be shown

Outputs

TypeNameDefaultDescription
StringstrFormatted return string