]> granicus.if.org Git - php/commit
Patch for bug #67839 (mysqli does not handle 4-byte floats correctly)
authorKeyur Govande <keyur_govande@yahoo.com>
Thu, 14 Aug 2014 18:19:56 +0000 (18:19 +0000)
committerKeyur Govande <keyur_govande@yahoo.com>
Thu, 14 Aug 2014 18:19:56 +0000 (18:19 +0000)
commitc044164a96553668cc6c4ae1eb32f18219308851
treeb43d8221a56ca7b6c3aa39a41cca8cc256cb289b
parentaeb633543bbd571d7fb440d54ae3b0f1a4dfece7
Patch for bug #67839 (mysqli does not handle 4-byte floats correctly)

Before the patch, a value of 9.99 in a FLOAT column came out of mysqli
as 9.9998998641968. This is because it would naively cast a 4-byte float
into PHP's internal 8-byte double.
To fix this, with GCC we use the built-in decimal support to "up-convert"
the 4-byte float to a 8-byte double.
When that is not available, we fall back to converting the float
to a string and then converting the string to a double. This mimics
what MySQL does.
ext/mysqli/tests/bug67839.phpt [new file with mode: 0644]
ext/mysqlnd/config9.m4
ext/mysqlnd/mysqlnd_ps_codec.c