1
0
mirror of synced 2025-12-15 01:28:09 +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 + "]");

View File

@@ -50,9 +50,9 @@ public class IdGeneratorOptions {
/**
* 最小序列数(含)
* 默认11,不小于5不大于MaxSeqNumber-2
* 默认5,不小于1不大于MaxSeqNumber-1
*/
public short MinSeqNumber = 11;
public short MinSeqNumber = 5;
/**
* 最大漂移次数(含)