|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30726 Negative floats <1 as strings don't work in calculations
Submitted: 2004-11-09 01:10 UTC Modified: 2005-01-18 01:31 UTC
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: degusta at yahoo dot com Assigned: iliaa (profile)
Status: Closed Package: Math related
PHP Version: 4CVS, 5CVS (2005-01-10) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: degusta at yahoo dot com
New email:
PHP Version: OS:


 [2004-11-09 01:10 UTC] degusta at yahoo dot com
Strings that are between 0 and -1 and don't have a leading zero, e.g. "-.2", "-.95", etc, do not get cast to floats.

This is a variant of bug 30069 which was closed with 4.3.9. That fix did solve the problem for positive floats (".1", ".4", etc), but apparently not for negative floats.

The bug is still present in CVS as of 11/8/04 (php4-STABLE-200411082130). I haven't checked the 5 branch yet, but my guess is that it's wrong there too since 30069 also existed in the 5 branch.

Every past version of PHP has cast this properly (up through and including 4.3.8).

Reproduce code:
echo '-.1' * 2;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-10 17:00 UTC]
See also bug #30069

This works fine with e.g. PHP 4.2.2 :)

 [2005-01-10 21:05 UTC]
Assigned to Ilia per his request.

 [2005-01-18 01:31 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 14:01:29 2024 UTC