.FaultTriggering.Utilities.Internal.Records.OutputHandling.FormatReal

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  "              

Interface

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;

Generated at 2024-12-22T19:25:51Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos