Skip to content

Commit d716e02

Browse files
author
Derick Rethans
committed
- Fix for bug #12383 and #14755: 105.05$ becomes 105.5$ (Patch by: Giancarlo
Niccolai <giancarlo@niccolai.org>)
1 parent 01505de commit d716e02

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

ext/interbase/interbase.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,11 +1783,22 @@ static int _php_ibase_var_pval(pval *val, void *data, int type, int len, int sca
17831783
break;
17841784
#ifdef SQL_INT64
17851785
case SQL_INT64:
1786-
Z_TYPE_P(val) = IS_STRING;
1787-
Z_STRLEN_P(val) = sprintf(string_data, "%Ld.%0*Ld",
1788-
(ISC_INT64) (*((ISC_INT64 *)data) / (int) pow(10.0, (double) -scale)), -scale,
1789-
(ISC_INT64) abs((int) (*((ISC_INT64 *)data) % (int) pow(10.0, (double) -scale))));
1790-
Z_STRVAL_P(val) = estrdup(string_data);
1786+
val->type = IS_STRING;
1787+
1788+
if (scale) {
1789+
int i, len;
1790+
char dt[20];
1791+
double number = (double) ((ISC_INT64) (*((ISC_INT64 *)data)));
1792+
1793+
number /= - 10 * scale;
1794+
sprintf(dt, "%%0.%df", -scale);
1795+
val->value.str.len = sprintf (string_data, dt, number);
1796+
} else {
1797+
val->value.str.len = sprintf (string_data, "%Ld",
1798+
(ISC_INT64) (*((ISC_INT64 *)data)));
1799+
}
1800+
1801+
val->value.str.val = estrdup(string_data);
17911802
break;
17921803
#endif
17931804
#ifndef SQL_TIMESTAMP

0 commit comments

Comments
 (0)