|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41951 floats are stored as ints
Submitted: 2007-07-10 13:54 UTC Modified: 2007-07-11 13:34 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rachmel at avaya dot com Assigned:
Status: Wont fix Package: *Math Functions
PHP Version: 5.2CVS-20070710 OS: WindRiver Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-07-10 13:54 UTC] rachmel at avaya dot com
I am cross compiling php from i686-red-hat linux plat to ppc-windriver linux plat.

The problem I see, is that when trying to assign a value bigger than MAX_INT (2147483648-1), the variable gets the value of MAX_INT-1.
This is not just an explicit variable issue. Just trying to 'echo' the same value results in the same problem.

When compiling for my i686 platform, this problem doesn't occur.
I am upgrading from php 5.1.4, and I didn't have any problems in that version.

Reproduce code:
        $a = 0x8fffffff;
        $b = 2415919103;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-10 14:38 UTC] rachmel at avaya dot com

I tried the CVS head version you offered me in the above link. The problem is still there, and the numbers are not converted to float as expected.
 [2007-07-11 07:22 UTC]
We don't have any PPC-windriver machines off hand, so I don't thin anybody is able to help you except for yourself.
 [2007-07-11 07:29 UTC] rachmel at avaya dot com
I see.. Well, can you at least give me directions?
Where can I find the code responsible for parsing numbers and deciding whether to save them as int / floats?

Thanks, Nir.
 [2007-07-11 07:40 UTC]
It's propably the cross-compiling causing this. It picks wrong values for certain defines. See for AC_CHECK_SIZEOF and PHP_CHECK_SIZEOF for examples. The last parameter in those is the value passed when cross-compiling. Also check the generated main/php_config.h which you better change before running make to change those to be correct. In any case, cross-compiling is something that we don't really support so I'm closing this report. 

 [2007-07-11 13:34 UTC] rachmel at avaya dot com

OK - I understand you aren't going to fix it, but I have found the problematic values and will post them here for others to benefit.

when the configure script tries to define the sizes of int, char etc. for a cross-compilation environment, it uses some predefined values that aren't necessarily fit. The values I had to changes were of:
(1) sizeof long
(2) sizeof ssize_t
(3) sizeof size_t

Thanks for the help,
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Jul 26 16:01:26 2021 UTC