mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
fixed Q_itohex not dealing with big numbers properly
This commit is contained in:
parent
7ea3b4264c
commit
172b6a0e9a
1 changed files with 4 additions and 3 deletions
|
@ -2942,21 +2942,22 @@ const char* Q_itohex( uint64_t number, qbool uppercase, qbool prefix )
|
|||
|
||||
const char* const lut = luts[uppercase == 0 ? 0 : 1];
|
||||
uint64_t x = number;
|
||||
int i = maxLength;
|
||||
int i = maxLength + 2;
|
||||
buffer[i] = '\0';
|
||||
while ( i-- ) {
|
||||
buffer[i] = lut[x & 15];
|
||||
x >>= 4;
|
||||
}
|
||||
|
||||
int startOffset = 0;
|
||||
for ( i = 0; i < maxLength - 1; i++, startOffset++ ) {
|
||||
int startOffset = 2;
|
||||
for ( i = 2; i < maxLength + 1; i++, startOffset++ ) {
|
||||
if ( buffer[i] != '0' )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( prefix ) {
|
||||
startOffset -= 2;
|
||||
buffer[startOffset + 0] = '0';
|
||||
buffer[startOffset + 1] = 'x';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue