Format number

Supported in: Batch

Formats a number to a specific number of decimal places.

Expression categories: Cast, Numeric, String

Declared arguments

  • Decimal places - The number of decimal places.
    Literal<Integer>
  • Number - The number to format.
    Expression<Numeric>

Output type: String

Examples

Example 1: Base case

Description: Formats a number to 2 decimal places. Argument values:

  • Decimal places: 2
  • Number: 1234.5678

Output: 1,234.57


Example 2: Base case

Description: Formats a float number to 1 decimal place. Argument values:

  • Decimal places: 1
  • Number: 1234.56

Output: 1,234.6


Example 3: Base case

Description: Formats an integer number with no decimal places. Argument values:

  • Decimal places: 2
  • Number: 1234

Output: 1,234.00


Example 4: Base case

Description: Formats a large number to 2 decimal places. Argument values:

  • Decimal places: 2
  • Number: 123456789.123456789

Output: 123,456,789.12


Example 5: Base case

Description: Formats a number with no decimal places. Argument values:

  • Decimal places: 0
  • Number: 1234.5678

Output: 1,235


Example 6: Null case

Description: Handles null input. Argument values:

  • Decimal places: 2
  • Number: number
numberOutput
nullnull

Example 7: Edge case

Description: Formats a number to 50 decimal places. Argument values:

  • Decimal places: 50
  • Number: 1234.0

Output: 1,234.00000000000000000000000000000000000000000000000000