Number.ToText

Syntax

Number.ToText(number as nullable number, optional format as nullable text, optional culture as nullable text) as nullable text 

About

Formats the numeric value number to a text value according to the format specified by format. The format is a single character code optionally followed by a number precision specifier. The following character codes may be used for format.

  • "D" or "d": (Decimal) Formats the result as integer digits. The precision specifier controls the number of digits in the output.
  • "E" or "e": (Exponential [scientific]) Exponential notation. The precision specifier controls the maximum number of decimal digits (default is 6).
  • "F" or "f": (Fixed-point) Integral and decimal digits.
  • "G" or "g": (General) Most compact form of either fixed-point or scientific.
  • "N" or "n": (Number) Integral and decimal digits with group separators and a decimal separator.
  • "P" or "p": (Percent) Number multiplied by 100 and displayed with a percent symbol.
  • "R" or "r": (Round-trip) A text value that can round-trip an identical number. The precision specifier is ignored.
  • "X" or "x": (Hexadecimal) A hexadecimal text value.

Example 1

Format a number as text without format specified.

Number.ToText(4)

"4"

Example 2

Format a number as text in Exponential format.

Number.ToText(4, "e")

"4.000000e+000"

Example 3

Format a number as text in Decimal format with limited precision.

Number.ToText(-0.1234, "P1")

"-12.3 %"