HH\Lib\Str\format_number

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

This function is available as Str\format_number() in Facebook's www repository.

Returns a string representation of the given number with grouped thousands

Description

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.

Parameters

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