var bucketSize = 8190; ... var bucketNumber = Math.floor(userId / bucketSize), bitInBucket = userId % bucketSize;