mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Add the sqlite3Int64ToText() routine and use it to convert integers to text,
as it is much faster than the generic text formatter. FossilOrigin-Name: 14eed318aa9e6e16d1aa13a9f34e3822aa135c39ba06c77df7743509fed6c95e
This commit is contained in:
24
src/util.c
24
src/util.c
@@ -595,6 +595,30 @@ do_atof_calc:
|
||||
#pragma warning(default : 4756)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Render an signed 64-bit integer as text. Store the result in zOut[].
|
||||
**
|
||||
** The caller must ensure that zOut[] is at least 21 bytes in size.
|
||||
*/
|
||||
void sqlite3Int64ToText(i64 v, char *zOut){
|
||||
int i;
|
||||
u64 x;
|
||||
char zTemp[22];
|
||||
if( v<0 ){
|
||||
x = (v==SMALLEST_INT64) ? ((u64)1)<<63 : -v;
|
||||
}else{
|
||||
x = v;
|
||||
}
|
||||
i = sizeof(zTemp)-2;
|
||||
zTemp[sizeof(zTemp)-1] = 0;
|
||||
do{
|
||||
zTemp[i--] = (x%10) + '0';
|
||||
x = x/10;
|
||||
}while( x );
|
||||
if( v<0 ) zTemp[i--] = '-';
|
||||
memcpy(zOut, &zTemp[i+1], sizeof(zTemp)-1-i);
|
||||
}
|
||||
|
||||
/*
|
||||
** Compare the 19-character string zNum against the text representation
|
||||
** value 2^63: 9223372036854775808. Return negative, zero, or positive
|
||||
|
||||
Reference in New Issue
Block a user