提交 cac6ede6 编写于 作者: Z zhouzj

修改约束条件

上级 85dfbd85
......@@ -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);
......
......@@ -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 + "]");
......
......@@ -50,9 +50,9 @@ public class IdGeneratorOptions {
/**
* 最小序列数(含)
* 默认11,不小于5,不大于MaxSeqNumber-2
* 默认5,不小于1,不大于MaxSeqNumber-1
*/
public short MinSeqNumber = 11;
public short MinSeqNumber = 5;
/**
* 最大漂移次数(含)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册