1
0
mirror of synced 2026-02-05 04:27:55 +08:00

修改约束条件

This commit is contained in:
zhouzj
2021-03-14 12:13:37 +08:00
parent 85dfbd8528
commit cac6ede6b7
3 changed files with 7 additions and 8 deletions

View File

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

View File

@@ -57,11 +57,10 @@ namespace Yitter.IdGenerator
}
var maxSeqNumber = Math.Pow(2, options.SeqBitLength) - 1;
if (options.MaxSeqNumber > maxSeqNumber)
{
options.MaxSeqNumber = (int)maxSeqNumber;
}
//if (options.MaxSeqNumber > maxSeqNumber)
//{
// options.MaxSeqNumber = (int)maxSeqNumber;
//}
if (options.MaxSeqNumber < 0 || options.MaxSeqNumber > maxSeqNumber)
{
throw new ApplicationException("MaxSeqNumber error. (range:[1, " + maxSeqNumber + "]");