Skip to content

Commit 85ffb7a

Browse files
committed
Restore rounded variable declaration removed by mistake
The previous commit (suggestion from GitHub UI) accidentally removed the declaration and computation of the 'rounded' variable while keeping its usage, causing a compilation error.
1 parent ebc9821 commit 85ffb7a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/standard/formatted_print.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
268268
&is_negative, &num_buf[1], &s_len);
269269
/* Prevent negative sign when value rounds to zero (GH-12237) */
270270
if (is_negative) {
271+
double rounded;
272+
if (fmt == 'f' || fmt == 'F') {
273+
double factor = pow(10.0, (double)precision);
274+
rounded = round(fabs(number) * factor) / factor;
275+
} else {
276+
rounded = fabs(number);
277+
}
271278
if (rounded == 0.0) {
272279
is_negative = false;
273280
}

0 commit comments

Comments
 (0)