public PBNumber(NumberCapacity inWidth, String inSign, String inExponent, String inMantissa, RoundingType inRounding) { this.width = inWidth; switch (this.width) { case NumberCapacity.PB32: { this.offset = NumberOffset.PB32; this.exponentLenght = NumberExponentLength.PB32; this.mantissaLenght = NumberMantissaLength.PB32; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB32]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB32]; break; } case NumberCapacity.PB64: { this.offset = NumberOffset.PB64; this.exponentLenght = NumberExponentLength.PB64; this.mantissaLenght = NumberMantissaLength.PB64; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB64]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB64]; break; } case NumberCapacity.PB128: { this.offset = NumberOffset.PB128; this.exponentLenght = NumberExponentLength.PB128; this.mantissaLenght = NumberMantissaLength.PB128; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB128]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB128]; break; } case NumberCapacity.PB256: { this.offset = NumberOffset.PB256; this.exponentLenght = NumberExponentLength.PB256; this.mantissaLenght = NumberMantissaLength.PB256; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB256]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB256]; break; } default: { break; } } this.name = "Name-" + this.width.ToString() + "[" + inSign + inExponent + "|" + inMantissa + "]"; this.sign = inSign; this.Exponent = inExponent; this.Mantissa = inMantissa; this.roundingType = inRounding; if (pbConvertion == null) pbConvertion = new PBConvertion(); }
public PBNumber(String inDigit, NumberCapacity inCapacity, RoundingType inRounding) : this(inCapacity) { String currentNumber = ""; this.InitValue = inDigit; IPBNumber.IFPartsOfNumber currentPartialNumber; IPBNumber.IFPartsOfNumber currentPartialNumber2cc; if (pbConvertion == null) pbConvertion = new PBConvertion(); currentNumber = pbConvertion.NormalizeNumber(inDigit, PBConvertion.ACCURANCY, IPBNumber.NumberFormat.INTEGER); currentPartialNumber = pbConvertion.DenormalizeNumber(currentNumber, IPBNumber.NumberFormat.INTEGER); currentPartialNumber2cc.Sign = currentPartialNumber.Sign; currentPartialNumber2cc.IntegerPart = pbConvertion.convert10to2IPart(currentPartialNumber.IntegerPart); currentPartialNumber2cc.FloatPart = pbConvertion.convert10to2FPart(currentPartialNumber.FloatPart); //Define Exponent before Mantissa for correct running algorithm selectExp(currentPartialNumber2cc, inCapacity, IPBNumber.NumberFormat.INTEGER); selectMantissa(currentPartialNumber2cc, inCapacity, IPBNumber.NumberFormat.INTEGER, inRounding); this.Sign = currentPartialNumber.Sign; }
public PBNumber(PBPrototype inNumberPrototype, NumberCapacity inCapacity, RoundingType inRounding) : this(inCapacity, inNumberPrototype.Sign, inNumberPrototype.Exponent, inNumberPrototype.Mantissa, inRounding) { if (pbConvertion == null) pbConvertion = new PBConvertion(); }
public PBNumber(NumberCapacity inWidth) { this.width = inWidth; switch (this.width) { case NumberCapacity.PB32: { this.offset = NumberOffset.PB32; this.exponentLenght = NumberExponentLength.PB32; this.mantissaLenght = NumberMantissaLength.PB32; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB32]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB32]; break; } case NumberCapacity.PB64: { this.offset = NumberOffset.PB64; this.exponentLenght = NumberExponentLength.PB64; this.mantissaLenght = NumberMantissaLength.PB64; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB64]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB64]; break; } case NumberCapacity.PB128: { this.offset = NumberOffset.PB128; this.exponentLenght = NumberExponentLength.PB128; this.mantissaLenght = NumberMantissaLength.PB128; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB128]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB128]; break; } case NumberCapacity.PB256: { this.offset = NumberOffset.PB256; this.exponentLenght = NumberExponentLength.PB256; this.mantissaLenght = NumberMantissaLength.PB256; this.mf = IPBNumber.NumberMFs[(int)NumberMF.PB256]; this.cf = IPBNumber.NumberCFs[(int)NumberCF.PB256]; break; } default: { break; } } this.name = "Name-" + this.width.ToString() + "[]"; if (pbConvertion == null) pbConvertion = new PBConvertion(); }