|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65212 problem if pass in numeric string containing a float between 0 and 1
Submitted: 2013-07-06 08:59 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: iam4webwork at hotmail dot com Assigned:
Status: Open Package: Math related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-07-06 08:59 UTC] iam4webwork at hotmail dot com
If you pass to base_convert a numeric string like "0.5", to have it converted 
from base 10 to base 16, PHP will interpret the input as decimal 5 and return 
hexadecimal 5.  I suspect that the problem lies internally in the logic of 

Test script:

Expected result:
I expected PHP to return a zero just as printf("%x","0.5") and dexhex() do.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-06 17:42 UTC] iam4webwork at hotmail dot com
_php_math_basetozval appears to be source of problem b/c while it mimics strtol, 
unlike strtol it fails to adequately deal with '.' being an illegal character. 
strtol disregards '.' and all subsequent input whereas _php_math_basetozval just 
skips the '.' and processes the next character.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 13:01:23 2020 UTC