sharp-biginteger/IntField.cs

31 lines
688 B
C#

using System;
using System.Linq.Expressions;
namespace BigInt
{
public class IntField
{
public static IntField Default { get; set; } = null; // new IntField(UBigInteger.ZERO.Resize(256) - 1);
public UInteger FieldModulo { get; private set; }
public int FieldWidth { get; private set; }
public IntField(UInteger p,int width){
this.FieldWidth = width;
this.FieldModulo = p;
}
public IntField(UInteger p){
this.FieldModulo = p;
this.FieldWidth = p.RawValue.Length << 5;
}
public UInteger Fit(UInteger value){
return value % FieldModulo;
}
public override string ToString(){
return String.Format("[IntField p={0}]",this.FieldModulo);
}
}
}