FormatNumber

(System Library)

Description:

Given a numeric value, returns a compactly formatted version containing a minimum 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 minimum number of significant digits to be returned from Value.
IntegerFlag

Optional. Any Boolean expression. If FALSE, integers are returned without modification. Defaults to FALSE.

If TRUE, the integer value is expressed in exponential notation if it would appear smaller that way, with the 'Digits' number of significant digits.

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.0054

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

The variable result will be  5.4e-05

  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  12345

  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  12345

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

The variable result will be  1234

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

The variable result will be  1234567890

  Number = 1234567890;
  Result = System.FormatNumber(Number,3, TRUE); 

The variable result will be  1.23e+09

  Number = 100000000000;
  Result = System.FormatNumber(Number,3, TRUE); 

The variable result will be  1e+11