1
0
mirror of synced 2025-12-16 18:18:10 +08:00

auto commit

This commit is contained in:
yitter
2021-03-27 18:14:02 +08:00
parent ea30df4254
commit 5692602660
6 changed files with 100 additions and 101 deletions

View File

@@ -103,7 +103,7 @@ namespace Yitter.IdGenerator
if (MaxSeqNumber == 0)
{
MaxSeqNumber = (int)Math.Pow(2, SeqBitLength) - 1;
MaxSeqNumber = (1 << SeqBitLength) - 1;
}
_TimestampShift = (byte)(WorkerIdBitLength + SeqBitLength);

View File

@@ -49,7 +49,7 @@ namespace Yitter.IdGenerator
throw new ApplicationException("errorWorkerIdBitLength + SeqBitLength <= 22");
}
var maxWorkerIdNumber = Math.Pow(2, options.WorkerIdBitLength) - 1;
var maxWorkerIdNumber = (1 << options.WorkerIdBitLength) - 1;
if (options.WorkerId < 0 || options.WorkerId > maxWorkerIdNumber)
{
throw new ApplicationException("WorkerId error. (range:[0, " + (maxWorkerIdNumber > 0 ? maxWorkerIdNumber : 63) + "]");
@@ -60,13 +60,13 @@ namespace Yitter.IdGenerator
throw new ApplicationException("SeqBitLength error. (range:[2, 21])");
}
var maxSeqNumber = Math.Pow(2, options.SeqBitLength) - 1;
var maxSeqNumber = (1 << options.SeqBitLength) - 1;
if (options.MaxSeqNumber < 0 || options.MaxSeqNumber > maxSeqNumber)
{
throw new ApplicationException("MaxSeqNumber error. (range:[1, " + maxSeqNumber + "]");
}
var maxValue = maxSeqNumber; // maxSeqNumber - 1;
var maxValue = maxSeqNumber;
if (options.MinSeqNumber < 1 || options.MinSeqNumber > maxValue)
{
throw new ApplicationException("MinSeqNumber error. (range:[1, " + maxValue + "]");