ID:               41328
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rgonzalez at gnt dot cc
-Status:           Open
+Status:           Feedback
 Bug Type:         *Math Functions
 Operating System: Linux Slackware 10.2
 PHP Version:      5.2.2
 New Comment:

Try newer GCC first.


Previous Comments:
------------------------------------------------------------------------

[2007-05-08 17:26:11] rgonzalez at gnt dot cc

Description:
------------
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
script:

<?php

$nt = 100;
$promrow2['uni_gifts'] = 1;
$promrow2['unidades'] = 10;
$calc_cnt=floor(($nt*$promrow2['uni_gifts'])/$promrow2['unidades']);

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.

Software:

PHP 5.2.2
GCC 3.2.2


Reproduce code:
---------------
<?php

$nt = 100;
$promrow2['uni_gifts'] = 1;
$promrow2['unidades'] = 10;
$calc_cnt=floor(($nt*$promrow2['uni_gifts'])/$promrow2['unidades']);

print $calc_cnt;

?>


Expected result:
----------------
10

Actual result:
--------------
:.0000000001


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41328&edit=1

Reply via email to