Ejemplo n.º 1
0
        /// <summary>
        /// Computes the sum of two double double numbers.
        /// </summary>
        /// <param name="x">The first number.</param>
        /// <param name="y">The second number.</param>
        /// <returns>The value of <paramref name="x"/> + <paramref name="y"/>.</returns>
        public static DoubleDouble operator +(DoubleDouble x, DoubleDouble y)
        {
            // Add high components
            ExtendedMath.TwoSum(x.hi, y.hi, out double sHi, out double sLo);

            if (ExtendedMath.IsNotFinite(sHi))
            {
                return((DoubleDouble)sHi);
            }

            // Add low components
            ExtendedMath.TwoSum(x.lo, y.lo, out double tHi, out double tLo);
            ExtendedMath.TwoSum(sHi, sLo + tHi, out double vHi, out double vLo);
            ExtendedMath.FastTwoSum(vHi, tLo + vLo, out double zHi, out double zLo);

            return(new DoubleDouble(zHi, zLo));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Computes the sum of two double double numbers.
        /// </summary>
        /// <param name="a">The first number.</param>
        /// <param name="b">The second number.</param>
        /// <returns>The value of <paramref name="a"/> + <paramref name="b"/>.</returns>
        public static DoubleDouble operator +(DoubleDouble a, DoubleDouble b)
        {
            // Add high components
            double sHi, sLo;

            ExtendedMath.TwoSum(a.hi, b.hi, out sHi, out sLo);

            // Add low components
            double tHi, tLo;

            ExtendedMath.TwoSum(a.lo, b.lo, out tHi, out tLo);

            double vHi, vLo;

            ExtendedMath.TwoSum(sHi, sLo + tHi, out vHi, out vLo);

            double zHi, zLo;

            ExtendedMath.FastTwoSum(vHi, tLo + vLo, out zHi, out zLo);

            return(new DoubleDouble(zHi, zLo));
        }