From:             oliver at teqneers dot de
Operating system: OpenSuSE 10.2
PHP version:      5.2.4RC1
PHP Bug Type:     *Configuration Issues
Bug description:  round will not use PHP_ROUND_FUZZ on 64bit CPUs

Description:
------------
Because of the nature of floats to be not exact enough in binary system,
PHP uses a kind of fuzzy login to round more precisely turning on
PHP_ROUND_FUZZ in some cases.

The problem is the "configure" check. The check does not work for AMD nor
INTEL 64bit CPUs.

The number to test against is not sufficient. So maybe it is possible to
add or change it???

Reproduce code:
---------------
#include <math.h>
  /* keep this out-of-line to prevent use of gcc inline floor() */
  double somefn(double n) {
    return floor(n*pow(10,2) + 0.5);
  }
  int main() {
    return somefn(0.045)/10.0 != 0.5;
  }

this will return 1 on a 32bit but 0 on a 64bit engine.

Expected result:
----------------
it should also fail on a 64bit and return 1. The following code would
actually work on 64bit, because it will test 0.45 as well as 0.285:


#include <math.h>
  /* keep this out-of-line to prevent use of gcc inline floor() */
  double somefn(double n) {
    return floor(n*pow(10,2) + 0.5);
  }
  int main() {
    return (somefn(0.285)/100.0 != 0.29) || (somefn(0.045) / 10.0 !=
0.5);
  }

Actual result:
--------------
Instead of using the fuzzy round, PHP just takes 0.5 and adds/substracts
it from the given float (math.c)

-- 
Edit bug report at http://bugs.php.net/?id=42294&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42294&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42294&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42294&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42294&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42294&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42294&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42294&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42294&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42294&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42294&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42294&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42294&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42294&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42294&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42294&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42294&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42294&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42294&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42294&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42294&r=mysqlcfg

Reply via email to