php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38374 Test of date_sunrise() and date_sunset() always FAIL on PPC64
Submitted: 2006-08-08 07:38 UTC Modified: 2006-08-09 06:27 UTC
From: liyanbj at cn dot ibm dot com Assigned:
Status: Closed Package: Date/time related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
 [2006-08-08 07:38 UTC] liyanbj at cn dot ibm dot com
Description:
------------
PROBLEM DESCRIPTION
===================
This problem happens on IBM PowerPC 64bit machine (PPC64) only, and is a testing related problem (i.e. not a problem of php base). The result of test "ext/standard/tests/general_functions/sunfuncts.phpt" on PPC64 differ from the result from other architectures slightly.  For example:

~~~~ SNIP FROM TEST OUTPUT ~~~~
003+ 1044073855 06:30 6.515408927984
003- 1044073855 06:30 6.515408927982
......
~~~~ SNIP FROM TEST OUTPUT ~~~~

The first line is the result seen on any architecture other than PPC64, while the second line is the result from PPC64 machines. 

I think it's due to the nuance between the implementation of PPC64 floating point related hardware and that of IA32.

According to common knowledge, two floating point numbers should never be compared for equality.  So I think we should just compare part of the result floating point numbers, say, a few digits from the beginning and ignore the trailing digits.



HARDWARE ENVIRONMENT
====================
/proc/cpuinfo:
processor       : 0
cpu             : POWER5 (gr)
clock           : 1498.500000MHz
revision        : 2.2 (pvr 003a 0202)

processor       : 1
cpu             : POWER5 (gr)
clock           : 1498.500000MHz
revision        : 2.2 (pvr 003a 0202)

timebase        : 187548000
machine         : CHRP IBM,9111-520


SOFTWARE ENVIRONMENT
====================
SUSE Linux Enterprise Server (SLES) 10.

Reproduce code:
---------------
On PPC64 machine, compile php and run all test, then check:
/ext/standard/tests/general_functions/sunfuncts.diff


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-08 07:45 UTC] liyanbj at cn dot ibm dot com
My idea on this kind of problem is that we should make a tiny modification to the testcase itself to make it more general.

My solution is to use substr() to truncate the floating point number output and keeps only those digits that precise enough and are identical on all architectures.  I can post my patch if you need it.
 [2006-08-08 12:08 UTC] tony2001@php.net
Please try using this CVS snapshot:

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


 [2006-08-09 06:27 UTC] liyanbj at cn dot ibm dot com
That's fine.  The solution is better than mine.  :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 05:01:31 2024 UTC