|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41328 Weird results from floor after compiling with pentium4 optimizations
Submitted: 2007-05-08 17:26 UTC Modified: 2007-05-16 01:00 UTC
From: rgonzalez at gnt dot cc Assigned:
Status: No Feedback Package: *Math Functions
PHP Version: 5.2.2 OS: Linux Slackware 10.2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-05-08 17:26 UTC] rgonzalez at gnt dot cc
I compiled PHP 5.2.2 with CFLAGS="-O2 -march=pentium4
-mcpu=pentium4", as usual (I've done so with all the 5.x.x series, and the
proc is a Pentium 4, of course) and a customer complained about weird
results in one of his scripts. I isolated the problem to be related to the
floor function. The problem was that it returned weird results. Sample


$nt = 100;
$promrow2['uni_gifts'] = 1;
$promrow2['unidades'] = 10;

print $calc_cnt;


printed :.0000000001

I needed to cast (int)floor to get the right result. I recompiled with CFLAGS="-O2 -march=i686 -mcpu=i686" and the problem was solved. I've compiled 5.2.2 with nocona optimizations without problems in other machines.


PHP 5.2.2
GCC 3.2.2

Reproduce code:

$nt = 100;
$promrow2['uni_gifts'] = 1;
$promrow2['unidades'] = 10;

print $calc_cnt;


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-08 17:44 UTC]
Try newer GCC first.
 [2007-05-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 23:03:35 2021 UTC