php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14402 round() outputs too many digits
Submitted: 2001-12-10 09:47 UTC Modified: 2002-01-02 14:06 UTC
From: michiel at parse dot nl Assigned:
Status: Closed Package: Math related
PHP Version: 4.1.0RC5 OS: Linux-2.4.14 (Slackware 8.0)
Private report: No CVE-ID: None
 [2001-12-10 09:47 UTC] michiel at parse dot nl
<?
$int = 0.293847289472983; 
echo $int ."\n"; 
echo round($int,2) . "\n"; 
echo round((int)$int,2) . "\n"; 
echo round((float)$int,2) . "\n"; 
echo round((double)$int,2) . "\n"; 
?>
outputs on php 4.0.6: 
0.29384728947298 
0.29 
0 
0.29 
0.29 

however, using php 4.1.0, it outputs: 
0.29384728947298299761570206101168878376483917236328125 
0.289999999999999980015985556747182272374629974365234375 
0 
0.289999999999999980015985556747182272374629974365234375 
0.289999999999999980015985556747182272374629974365234375 

is this a bug, or a new 'feature' ? Closest report I found was http://marc.theaimsgroup.com/?l=php-dev&m=100750316722784&w=2 on the php-dev mailinglist.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-10 09:51 UTC] michiel at parse dot nl
Changed distro/php version for clarity.
 [2001-12-11 16:16 UTC] derick@php.net
weird, this works fine for me (PHP cgi).

Derick
 [2001-12-12 11:30 UTC] sniper@php.net
can't reproduce either with PHP 4.2.0-dev.

Try the latest CVS snapshot: http://snaps.php.net/

--Jani

 [2002-01-02 14:06 UTC] lobbin@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 30 22:01:28 2024 UTC