php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #16946 number_format documentation example problem
Submitted: 2002-05-01 10:26 UTC Modified: 2002-05-07 10:30 UTC
From: hpdl at oscommerce dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.2 OS: documentation
Private report: No CVE-ID: None
 [2002-05-01 10:26 UTC] hpdl at oscommerce dot com
The example listed on the number_format page is not taking into account the rounding of the value returned.

http://www.php.net/manual/en/function.number-format.php

<?php

    $number = 1234.56;

    // english notation (default)
    $english_format_number = number_format($number);
    // 1,234.56

    // French notation
    $nombre_format_francais = number_format($number, 2, ',', ' ');
    // 1 234,56

    $number = 1234.5678;

    // english notation without thousands seperator
    $english_format_number = number_format($number, 2, '.', '');
    // 1234.56

?>

The last output should be 1234.57

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-02 06:48 UTC] sander@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/


 [2002-05-07 10:30 UTC] hpdl at oscommerce dot com
could the rounding feature of number_format be documented?

also the empty/no thousands separator does not seem to work with php3 (as mentioned in the comments) - perhaps this should be documented as a php4 only feature too?

thanks for your time
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 20:01:27 2024 UTC