php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33584 round problems
Submitted: 2005-07-06 11:27 UTC Modified: 2005-07-07 18:38 UTC
From: ruslan_y at list dot ru Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.11 OS: Linux Fedore Core 4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ruslan_y at list dot ru
New email:
PHP Version: OS:

 

 [2005-07-06 11:27 UTC] ruslan_y at list dot ru
Description:
------------
It's something wrong with round() and number_format() function on "new" Fedora Core 4.

I'm try to compile php4.4.0RC2 on the same box but get just the same result. 

Configure options:
'./configure' '--prefix=/usr/local' '--program-suffix=4' '--with-config-file-path=/etc/php4' '--enable-memory-limit' '--enable-versioning' '--enable-bcmath' '--with-apxs=/usr/local/httpd/bin/apxs' '--disable-cgi' '--enable-sigchild' '--with-zlib' '--enable-calendar' '--with-dom' '--with-zlib-dir' '--with-dom-xslt' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-ttf' '--with-freetype-dir' '--enable-gd-native-ttf' '--with-iconv' '--with-mysql' '--with-oci8' '--enable-xslt' '--with-xslt-sablot' '--with-expat' '--with-iconv-dir' '--without-pear'

OS:
Linux - Linux localhost.localhost 2.6.11-1.1369_FC4smp #1 SMP Thu Jun 2 23:08:39 EDT 2005 i686

Automake: automake (GNU automake) 1.9.5
Autoconf: autoconf (GNU Autoconf) 2.59
Libtool: ltmain.sh (GNU libtool) 1.4.3 (1.922.2.111 2002/10/23 02:54:36)

Compiler:
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)

Bison: bison (GNU Bison) 2.0


Reproduce code:
---------------
<?php
echo "<br/>0.112=>".round(0.112, 2);
echo "<br/>0.115=>".round(0.115, 2);
echo "<br/>0.105=>".round(0.105, 2);
echo "<br/>0.107=>".round(0.107, 2);
?>

Expected result:
----------------
0.112=>0.11
0.115=>0.12
0.105=>0.11
0.107=>0.11

Actual result:
--------------
0.112=>0.11
0.115=>0.12
0.105=>0.1
0.107=>0.11

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-06 12:27 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-07-06 13:45 UTC] ruslan_y at list dot ru
It's all right with php5-latest (php5-200507060830)
I've got the results as expected:
0.112=>0.11
0.115=>0.12
0.105=>0.11
0.107=>0.11

But It's still a problem with (php4-STABLE-200507060848) on this server. I'm try to reproduce problem on the same version of php on other server (ALT Linux) and did not get any trouble. So it's seems to be Fedora specific (IMHO)
 [2005-07-06 20:16 UTC] ruslan_y at list dot ru
I've made some research and got the solution...

If I'm using gcc4 the round() function is broken
---
#gcc -v 
...
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)
---

but after installing gcc2.96 and recompiling php (./configure; make)
---
#gcc -v 
...
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-126)
---
round() works just fine.
 [2005-07-07 18:38 UTC] sniper@php.net
Compiler bugs are not PHP bugs.

 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jan 28 19:03:44 2023 UTC