diff options
author | Anatol Belski <ab@php.net> | 2014-09-10 19:32:25 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-09-10 19:32:25 +0200 |
commit | e699f654f0c4b00fd4e915829842c43aa9c6f7b9 (patch) | |
tree | 10685f35448e5afd4b970ccebf5fa9ce01953e48 /ext/mysqlnd/mysqlnd_ps_codec.c | |
parent | 80ef586541c8323974eff5f5a448a7756b857fef (diff) | |
parent | 0b89bb83ba1302c454965676e6ccfb094f2b3745 (diff) | |
download | php-git-e699f654f0c4b00fd4e915829842c43aa9c6f7b9.tar.gz |
Merge branch 'PHP-5.6'
* PHP-5.6:
fix precision when fetching float through mysqlnd
Diffstat (limited to 'ext/mysqlnd/mysqlnd_ps_codec.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps_codec.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index 7cb462960b..8f83a9e2af 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -200,17 +200,27 @@ ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* The following cast is guaranteed to do the right thing */ dval = (double) d32val; } +#elif defined(PHP_WIN32) + { + /* float datatype on Winows is already 4 byte but has a precision of 7 digits */ + char num_buf[2048]; + (void)_gcvt_s(num_buf, 2048, fval, field->decimals >= 31 ? 7 : field->decimals); + dval = zend_strtod(num_buf, NULL); + } #else { char num_buf[2048]; /* Over allocated */ char *s; +#ifndef FLT_DIG +# define FLT_DIG 6 +#endif /* Convert to string. Ignoring localization, etc. * Following MySQL's rules. If precision is undefined (NOT_FIXED_DEC i.e. 31) * or larger than 31, the value is limited to 6 (FLT_DIG). */ s = php_gcvt(fval, - field->decimals >= 31 ? 6 : field->decimals, + field->decimals >= 31 ? FLT_DIG : field->decimals, '.', 'e', num_buf); |