What’s the Real Range of Tencent QQ Numbers and How Bitmap Handles Their Deduplication?
This article explains the theoretical and practical range of Tencent QQ numbers, why the lower limit is set to 10001, how unused accounts are reclaimed, and demonstrates how bitmap techniques can efficiently deduplicate billions of QQ IDs using simple C++ code.
1. QQ Number Range
QQ numbers are stored as a 32‑bit unsigned integer, so the theoretical range is [0, 2^32‑1] (0 to 4,294,967,295). In practice the minimum valid ID is 10001, a legacy constraint from early Tencent systems. The following code snippet shows how the backend validates the ID:
unsigned int uin = getFromCookie(cookie, "uin");
if ( uin < 10001 ) {
log.Error("invalid uin %u", uin);
return INVALID_UIN ;
}The maximum 10‑digit value 4,294,967,295 (≈43 billion) has never been observed in the wild.
2. What Happens When QQ Numbers Are Exhausted?
QQ’s active user base is far below the theoretical limit, and Tencent imposes registration restrictions, so the 43 billion ceiling is not a near‑term concern. Accounts that remain inactive for long periods are eventually reclaimed, preventing resource waste.
3. QQ Numbers and Bitmap
Interview questions often use QQ IDs to test bitmap knowledge. A bitmap can represent the existence of each possible ID with one bit. An unsigned char (8 bits) tracks 0‑7, an unsigned int (32 bits) tracks 0‑31, and two unsigned int values can cover 0‑63, and so on.
With 512 MB of memory (≈2^32 bits) you can represent the presence of every possible QQ number.
#include <iostream>
#include <set>
#include <cstring>
using namespace std;
#define N 20 // numbers 0‑19
#define SHIFT 5
#define MASK 0x1f
unsigned int a[1 + N / 32] = {0};
// set bit i to 1
void setOne(int i) { a[i >> SHIFT] |= (1 << (i & MASK)); }
// set bit i to 0
void setZero(int i) { a[i >> SHIFT] &= ~(1 << (i & MASK)); }
// get state of bit i
int getState(int i) { return (a[i >> SHIFT] & (1 << (i & MASK))) && 1; }
int main() {
setOne(1); setOne(3); setOne(1); setOne(4); setOne(9); setOne(9); setOne(9);
for(int i = 0; i < N; ++i) {
cout << i << " corresponding state: " << getState(i) << endl;
}
return 0;
}Running the program yields:
0 corresponding state: 0
1 corresponding state: 1
2 corresponding state: 0
3 corresponding state: 1
4 corresponding state: 1
5 corresponding state: 0
6 corresponding state: 0
7 corresponding state: 0
8 corresponding state: 0
9 corresponding state: 1
10 corresponding state: 0
... (remaining values are 0)Understanding this bitmap approach helps solve large‑scale deduplication problems, such as handling 40 billion QQ IDs efficiently.
NiuNiu MaTe
Joined Tencent (nicknamed "Goose Factory") through campus recruitment at a second‑tier university. Career path: Tencent → foreign firm → ByteDance → Tencent. Started as an interviewer at the foreign firm and hopes to help others.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
