#21801 [Com]: number_format do not round correctly

From: Date: Wed, 20 Oct 2004 07:14:38 +0000
Subject: #21801 [Com]: number_format do not round correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-67807@lists.php.net to get a copy of this message
ID: 21801 Comment by: jonas at ponas dot lt Reported By: supad at noos dot fr Status: Closed Bug Type: *Math Functions Operating System: Linux PHP Version: 4.2.2 New Comment: echo round(0.0445, 2);// prints 0.04 Previous Comments: ------------------------------------------------------------------------ [2003-01-21 14:10:56] iliaa@php.net In 4.3 both round() and number_format() round 0.5 to 1. Keep in mind that this may also depend on your libc, which is what doing the rounding. ------------------------------------------------------------------------ [2003-01-21 12:38:38] supad at noos dot fr <? echo number_format(0.49)."<br>"; echo number_format(0.50)."<br>"; echo number_format(0.51)."<br><br>"; echo round(0.49)."<br>"; echo round(0.50)."<br>"; echo round(0.51)."<br>"; ?> returns 0 0 1 0 1 1 number_format do not round correctly while round does. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21801&edit=1

« previous php.bugs (#67807) next »