HH\Lib\Str\format_number

Meta Engineer?

This is available as Str\format_number in the www repository.

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.

Guide

Parameters

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

Returns

  • string