-
-
Save anonymous/1928c3d51130f56e8fae597494c64aa4 to your computer and use it in GitHub Desktop.
Replace lines 28834-28889
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){ | |
i64 iA = *pA; | |
testcase( iA==0 ); testcase( iA==1 ); | |
testcase( iB==-1 ); testcase( iB==0 ); | |
if( iB>=0 ){ | |
testcase( iA>0 && LARGEST_INT64 - iA == iB ); | |
testcase( iA>0 && LARGEST_INT64 - iA == iB - 1 ); | |
if( iA>0 && LARGEST_INT64 - iA < iB ) return 1; | |
}else{ | |
testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 1 ); | |
testcase( iA<0 && -(iA + LARGEST_INT64) == iB + 2 ); | |
if( iA<0 && -(iA + LARGEST_INT64) > iB + 1 ) return 1; | |
} | |
*pA += iB; | |
return 0; | |
} | |
SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){ | |
testcase( iB==SMALLEST_INT64+1 ); | |
if( iB==SMALLEST_INT64 ){ | |
testcase( (*pA)==(-1) ); testcase( (*pA)==0 ); | |
if( (*pA)>=0 ) return 1; | |
*pA -= iB; | |
return 0; | |
}else{ | |
return sqlite3AddInt64(pA, -iB); | |
} | |
} | |
SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){ | |
i64 iA = *pA; | |
if( iB>0 ){ | |
if( iA>LARGEST_INT64/iB ) return 1; | |
if( iA<SMALLEST_INT64/iB ) return 1; | |
}else if( iB<0 ){ | |
if( iA>0 ){ | |
if( iB<SMALLEST_INT64/iA ) return 1; | |
}else if( iA<0 ){ | |
if( iB==SMALLEST_INT64 ) return 1; | |
if( iA==SMALLEST_INT64 ) return 1; | |
if( -iA>LARGEST_INT64/-iB ) return 1; | |
} | |
} | |
*pA = iA*iB; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment