FormatNumber

(System Library)

Description: Given a numeric value, returns a compactly formatted version of this number containing at least the specified number of significant digits.
Returns: Text
Usage: Script or steady state.
Function Groups: Math - Rounding Functions
Related to: Format | FormatInteger
Format: System.FormatNumber(Value, Digits[, IntegerFlag])
Parameters:  
Value
Required. Any numeric expression giving the original value to be formatted.
Digits
Required. Any numeric expression giving the number of significant digits to be returned from Value.
IntegerFlag
Optional. Any Boolean expression. If FALSE, integers are returned without modification. Defaults to FALSE.
Comments Must be preceded by System. This is primarily a significant digits function, but will also return an exponential value if the number of leading or trailing zeros is greater than three.
If the number is a non-integer, its significant digits are limited (to four digits by default). If the number can be shown with fewer characters using scientific notation, that notation is used. Integers are left untouched unless otherwise directed by an optional parameter.

Example:

  Number = 0.0054321;
  Result = System.FormatNumber(Number,2); 

The variable result will be  0.00054

  Number = 0.000054321;
  Result = System.FormatNumber(Number,2); 

The variable result will be  5.4e-005

  Number = 0.00455321;
  Result = System.FormatNumber(Number,2); 

The variable result will be  0.0046

  Number = 0.00454321;
  Result = System.FormatNumber(Number,2); 

The variable result will be  0.0045

  Number = 12345.54321;
  Result = System.FormatNumber(Number,3); 

The variable result will be  12300

  Number = 12345;
  Result = System.FormatNumber(Number,2); 

The variable result will be  12345

  Number = 12345;
  Result = System.FormatNumber(Number,2, 1); 

The variable result will be  12000