aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-06-12 20:51:38 +0000
committerdrh <drh@noemail.net>2019-06-12 20:51:38 +0000
commit13d04020775b10b252029455d2b8dcfcf49a47e4 (patch)
tree825af7b52ec8dab71c7d52c541cd01660ee5a4e1 /src
parent6ece353f2d2223ec78e63ce972081a047e89a641 (diff)
downloadsqlite-13d04020775b10b252029455d2b8dcfcf49a47e4.tar.gz
sqlite-13d04020775b10b252029455d2b8dcfcf49a47e4.zip
As a special case, casting '-0.0' into numeric should yield 0.
Fix for ticket [674385aeba91c774]. FossilOrigin-Name: 491f0f9bbddb6302536d99abd1ea481fd747ddcf6c6eaaacc0338d147b119081
Diffstat (limited to 'src')
-rw-r--r--src/vdbemem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/vdbemem.c b/src/vdbemem.c
index 20e1fb77e..c0e386ef6 100644
--- a/src/vdbemem.c
+++ b/src/vdbemem.c
@@ -693,14 +693,17 @@ int sqlite3VdbeMemRealify(Mem *pMem){
/* Compare a floating point value to an integer. Return true if the two
** values are the same within the precision of the floating point value.
**
+** This function assumes that i was obtained by assignment from r1.
+**
** For some versions of GCC on 32-bit machines, if you do the more obvious
** comparison of "r1==(double)i" you sometimes get an answer of false even
** though the r1 and (double)i values are bit-for-bit the same.
*/
int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
double r2 = (double)i;
- return memcmp(&r1, &r2, sizeof(r1))==0
- && i >= -2251799813685248 && i < 2251799813685248;
+ return r1==0.0
+ || (memcmp(&r1, &r2, sizeof(r1))==0
+ && i >= -2251799813685248 && i < 2251799813685248);
}
/*