Skip to content

number_format shouldn't round #19561

@simplysara

Description

@simplysara

Description

From manual page: https://php.net/function.number-format

Why is this method rounding. It should simply format the number. If I wanted to round I would use round().

// rounding the number

Documentation in lib file mentions nothing about rounding.
`/**

  • Format a number with grouped thousands
  • @link https://php.net/manual/en/function.number-format.php
  • @param float $num

  • The number being formatted.
  • @param int $decimals [optional]

  • Sets the number of decimal points.
  • @param string|null $decimal_separator [optional]
  • @param string|null $thousands_separator [optional]
  • @return string A formatted version of number.
    */
    #[Pure]
    function number_format(float $num, int $decimals = 0, ?string $decimal_separator = '.', ?string $thousands_separator = ','): string {}
    `

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions