diff options
author | drh <drh@noemail.net> | 2019-05-30 13:47:10 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-05-30 13:47:10 +0000 |
commit | 84422db987f3e26545760984ace02515eed1542c (patch) | |
tree | a7eee3922d75d745399533ddfff6a08012900f81 /src/func.c | |
parent | 05921223c25ae385a5e17bbf5484f5885bb78f2c (diff) | |
download | sqlite-84422db987f3e26545760984ace02515eed1542c.tar.gz sqlite-84422db987f3e26545760984ace02515eed1542c.zip |
Optimization to the round() SQL function for large input values without a
fractional part.
FossilOrigin-Name: e95138f5f4febde598f39e031d6e4f4d5ad0adbd8dcdd34fd0baaa78ab393417
Diffstat (limited to 'src/func.c')
-rw-r--r-- | src/func.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/func.c b/src/func.c index 313a14018..80c595a55 100644 --- a/src/func.c +++ b/src/func.c @@ -387,10 +387,10 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ ** handle the rounding directly, ** otherwise use printf. */ - if( n==0 && r>=0 && r<LARGEST_INT64-1 ){ - r = (double)((sqlite_int64)(r+0.5)); - }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){ - r = -(double)((sqlite_int64)((-r)+0.5)); + if( r<-4503599627370496.0 || r>+4503599627370496.0 ){ + /* The value has no fractional part so there is nothing to round */ + }else if( n==0 ){ + r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5))); }else{ zBuf = sqlite3_mprintf("%.*f",n,r); if( zBuf==0 ){ |