1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Simplifications to the overflow-free multiplier. Also remove some commented-out

code that was left in that subroutine by mistake on the previous check-in.

FossilOrigin-Name: 55fc25fdab61e6094289e068c343e012fec10439
This commit is contained in:
drh
2011-03-05 21:41:34 +00:00
parent 158b9cb965
commit d7255a207e
3 changed files with 12 additions and 14 deletions

View File

@@ -1121,15 +1121,13 @@ int sqlite3MulInt64(i64 *pA, i64 iB){
i64 iA = *pA;
i64 iA1, iA0, iB1, iB0, r;
// if( iB==1 ){ return 0; }
// if( iA==1 ){ *pA = iB; return 0; }
iA1 = iA/TWOPOWER32;
iA0 = iA % TWOPOWER32;
iB1 = iB/TWOPOWER32;
iB0 = iB % TWOPOWER32;
if( iA1*iB1 != 0 ) return 1;
r = iA1*iB0;
if( sqlite3AddInt64(&r, iA0*iB1) ) return 1;
assert( iA1*iB0==0 || iA0*iB1==0 );
r = iA1*iB0 + iA0*iB1;
testcase( r==(-TWOPOWER31)-1 );
testcase( r==(-TWOPOWER31) );
testcase( r==TWOPOWER31 );