This API is part of the Hack Standard Library, not HHVM itself.

Returns a string representation of the given number with grouped thousands

namespace HH\Lib\Str;

function format_number(
  num $number,
  int $decimals = 0,
  string $decimal_point = '.',
  string $thousands_separator = ',',
): string;

If $decimals is provided, the string will contain that many decimal places. The optional $decimal_point and $thousands_separator arguments define the strings used for decimals and commas, respectively.


  • num $number
  • int $decimals = 0
  • string $decimal_point = '.'
  • string $thousands_separator = ','