php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42989 Diffrent results on windows and linux with same script
Submitted: 2007-10-16 12:59 UTC Modified: 2007-10-25 13:52 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: naox at o2 dot pl Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.4 OS: linux and windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: naox at o2 dot pl
New email:
PHP Version: OS:

 

 [2007-10-16 12:59 UTC] naox at o2 dot pl
Description:
------------
Following script will output DIFFRENT result on windows and linux. Tested with php-5.2.4, php-5.2.0, php-4.4.7

PHP compiled on linux centos 4.5
root@sv2 [/usr] uname -a
Linux sv2.vipserv.org 2.6.21.5-grsec-xxxx-grs-ipv4-32 #7 SMP Thu Sep 13 10:22:01 CEST 2007 i686 i686 i386 GNU/Linux

with 
'./configure' '--prefix' '/usr/php-5.2.4.cgi' '--enable-force-cgi-redirect' '--with-xml' '--with-curl=/usr/curl' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr' '--with-xpm-dir=/usr/X11R6' '--with-iconv' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-pear' '--with-pgsql=/var/pgsql/bin/pg_config' '--enable-sockets' '--enable-track-vars' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-zlib' '--with-gettext' '--enable-bcmath' '--with-bz2' '--with-mysqli=/var/mysql5/bin/mysql_config' '--with-mysql=/var/mysql5' '--with-pdo' '--with-pdo-mysql' '--without-sqlite' '--with-xsl' '--enable-mbstring' '--with-pdo-pgsql' '--enable-soap'

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

$a = (float) -4738698913;
$g = (int) 43814;

$a ^= $g;

echo $a;

?>

Expected result:
----------------
On windows:
-443704711

On linux:
-2147439834

Windows output is correct result!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-16 17:10 UTC] naox at o2 dot pl
This actualy comes downs to this:

<?php
$a = -4738698913;
echo sprintf('%b', $a);
?>

On windows it produces proper
11100101100011010011000101011111
However on linux its
10000000000000000000000000000000
 [2007-10-25 13:52 UTC] jani@php.net
And on a 64bit machine I get: -4738672007 which is the only correct answer. You're trying to deal with bigger numbers than your OS/CPU allows. Not a PHP bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 03:01:32 2024 UTC