public IEEE754(ref IEEE754 iEEE, Formats formats) { var tmp = new IEEE754(iEEE.ToString(), formats); Significand_bits = new bool[tmp.Significand_bits.LongLength]; Exponent_bits = new bool[tmp.Exponent_bits.LongLength]; sign = tmp.sign; tmp.Significand_bits.CopyTo(Significand_bits, 0); tmp.Exponent_bits.CopyTo(Exponent_bits, 0); }
public IEEE754(ref IEEE754 iEEE) { GetFormats = iEEE.GetFormats; Significand_bits = new bool[iEEE.Significand_bits.LongLength]; Exponent_bits = new bool[iEEE.Exponent_bits.LongLength]; sign = iEEE.sign; iEEE.Significand_bits.CopyTo(Significand_bits, 0); iEEE.Exponent_bits.CopyTo(Exponent_bits, 0); }
public static IEEE754 operator +(IEEE754 a, IEEE754 b) { IEEE754 a_256 = (a.GetFormats == Formats.binary256) ? a : new IEEE754(ref a, Formats.binary256); IEEE754 b_256 = (b.GetFormats == Formats.binary256) ? b : new IEEE754(ref b, Formats.binary256); var a_e = ArrayToInt(ref a.Exponent_bits); var b_e = ArrayToInt(ref b.Exponent_bits); bool sign = false; bool[] Significand_bits = new bool[a.Significand_bits.LongLength]; bool[] Exponent_bits = new bool[a.Exponent_bits.LongLength]; if (a_e > b_e) { var gap = a_e - b_e; Shift(ref b_256.Significand_bits, gap); a_256.Exponent_bits.CopyTo(Exponent_bits, 0); } else { var gap = b_e - a_e; Shift(ref a_256.Significand_bits, gap); b_256.Exponent_bits.CopyTo(Exponent_bits, 0); } Minus(a_256.sign, ref a_256.Significand_bits); Minus(b_256.sign, ref b_256.Significand_bits); var tmp = Add(ref a_256.Significand_bits, ref b_256.Significand_bits); sign = tmp[0]; Minus(sign, ref tmp); tmp.CopyTo(Significand_bits, 0); return(new IEEE754(sign, Significand_bits, Exponent_bits)); }