diff options
author | drh <drh@noemail.net> | 2013-11-26 15:45:02 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-11-26 15:45:02 +0000 |
commit | de1a8b8c691ecc8be8b9741b6b5b5cd141c8c3da (patch) | |
tree | dbea3ec5c8f09d9b3401ee1eb836e07c1ca4216c /src/util.c | |
parent | dad19c320475942a449ac6f9817a4d06dfddf392 (diff) | |
download | sqlite-de1a8b8c691ecc8be8b9741b6b5b5cd141c8c3da.tar.gz sqlite-de1a8b8c691ecc8be8b9741b6b5b5cd141c8c3da.zip |
Change the REAL-to-INTEGER casting behavior so that if the REAL value
is greater than 9223372036854775807.0 then it is cast to the latest
possible integer, 9223372036854775807. This is sensible and the way
most platforms work in hardware. The former behavior was that oversize
REALs would be cast to the smallest possible integer, -9223372036854775808,
which is the way Intel hardware works.
FossilOrigin-Name: 6f53fc7106658d44edf63068f9a8522fa5a7688b
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c index 50ffd9865..5aa8af68d 100644 --- a/src/util.c +++ b/src/util.c @@ -512,7 +512,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ u = u*10 + c - '0'; } if( u>LARGEST_INT64 ){ - *pNum = SMALLEST_INT64; + *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64; }else if( neg ){ *pNum = -(i64)u; }else{ @@ -543,7 +543,6 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ /* zNum is exactly 9223372036854775808. Fits if negative. The ** special case 2 overflow if positive */ assert( u-1==LARGEST_INT64 ); - assert( (*pNum)==SMALLEST_INT64 ); return neg ? 0 : 2; } } |