Avoid using the internal printf routine for round(x,y) in the common case where y==0.
FossilOrigin-Name: d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf
This commit is contained in:
parent
35c1a793ce
commit
147e176aff
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C More\srounding\stests.
|
||||
D 2010-02-17T03:57:59
|
||||
C Avoid\susing\sthe\sinternal\sprintf\sroutine\sfor\sround(x,y)\sin\sthe\scommon\scase\swhere\sy==0.
|
||||
D 2010-02-17T04:19:27
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -120,7 +120,7 @@ F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581
|
||||
F src/expr.c d0a345e1d8995e142bc5d9f39a97b9981d7d8f23
|
||||
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
|
||||
F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0
|
||||
F src/func.c 7cd1b3abad8bcccf555fad9274d608da972467a3
|
||||
F src/func.c 3864490a90a03ab1d657cdd04da78879c18b18d1
|
||||
F src/global.c 75946a4a2ab41c6ae58f10ca0ed31b3449694b26
|
||||
F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af
|
||||
F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970
|
||||
@ -788,7 +788,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P c419955df0ad0507ecb3869786d48458366d4e8f
|
||||
R 0374c8d9925a8aac2f74883dcb36ba86
|
||||
P 3863638b8cd8d41cf4abf8b0d618892de845e91f
|
||||
R 4a859d44fd44fb2e90c77b0569157d3b
|
||||
U shaneh
|
||||
Z b4ee0a92d3d0f07e677dbd80998fc3a0
|
||||
Z 9dee3f892d9b2c7e04d5a57e6362923c
|
||||
|
@ -1 +1 @@
|
||||
3863638b8cd8d41cf4abf8b0d618892de845e91f
|
||||
d76ad8b3c494ffb4e670da0e92a1f8dbf7f48daf
|
18
src/func.c
18
src/func.c
@ -271,14 +271,24 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||
}
|
||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||
r = sqlite3_value_double(argv[0]);
|
||||
zBuf = sqlite3_mprintf("%.*f",n,r);
|
||||
if( zBuf==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
/* If Y==0 and X will fit in a 64-bit int,
|
||||
** 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));
|
||||
}else{
|
||||
zBuf = sqlite3_mprintf("%.*f",n,r);
|
||||
if( zBuf==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
return;
|
||||
}
|
||||
sqlite3AtoF(zBuf, &r);
|
||||
sqlite3_free(zBuf);
|
||||
sqlite3_result_double(context, r);
|
||||
}
|
||||
sqlite3_result_double(context, r);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user