Skip to content

Commit 9273480

Browse files
committed
feedback
1 parent a5d3258 commit 9273480

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Zend/zend_operators.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,13 @@ ZEND_API double ZEND_FASTCALL zval_try_get_double_func(const zval *op, bool *fai
10971097
return 0.0;
10981098
}
10991099
}
1100-
return type == IS_LONG ? (double) lval : dval;
1100+
if (type == IS_DOUBLE) {
1101+
return dval;
1102+
}
1103+
if (UNEXPECTED(lval == 0)) {
1104+
return zend_strtod(Z_STRVAL_P(op), NULL);
1105+
}
1106+
return (double) lval;
11011107
}
11021108
case IS_OBJECT:
11031109
{

ext/standard/tests/strings/pack_float_conversion.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ foreach ($formats as $format) {
4343
var_dump($infinity === INF && is_nan($nan));
4444
}
4545

46+
echo "signed zero integer strings:\n";
47+
foreach ($formats as $format) {
48+
$actual = unpack($format, pack($format, '-0'))[1];
49+
echo "$format: ";
50+
var_dump($actual === 0.0 && fdiv(1.0, $actual) === -INF);
51+
}
52+
4653
echo "leading-numeric strings:\n";
4754
foreach ($formats as $format) {
4855
$diagnostic = null;
@@ -139,6 +146,13 @@ G: bool(true)
139146
d: bool(true)
140147
e: bool(true)
141148
E: bool(true)
149+
signed zero integer strings:
150+
f: bool(true)
151+
g: bool(true)
152+
G: bool(true)
153+
d: bool(true)
154+
e: bool(true)
155+
E: bool(true)
142156
leading-numeric strings:
143157
f: bool(true)
144158
g: bool(true)

0 commit comments

Comments
 (0)