Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static double TruncateToPowerOfTwo(double d)
        {
            var db = new DoubleBits(d);

            db.ZeroLowerBits(52);
            return(db.Double);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d1"></param>
        /// <param name="d2"></param>
        /// <returns></returns>
        public static double MaximumCommonMantissa(double d1, double d2)
        {
            if (d1 == 0.0 || d2 == 0.0)
            {
                return(0.0);
            }

            var db1 = new DoubleBits(d1);
            var db2 = new DoubleBits(d2);

            if (db1.Exponent != db2.Exponent)
            {
                return(0.0);
            }

            int maxCommon = db1.NumCommonMantissaBits(db2);

            db1.ZeroLowerBits(64 - (12 + maxCommon));
            return(db1.Double);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="d"></param>
 /// <returns></returns>
 public static double TruncateToPowerOfTwo(double d)
 {
     DoubleBits db = new DoubleBits(d);
     db.ZeroLowerBits(52);
     return db.Double;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="d1"></param>
        /// <param name="d2"></param>
        /// <returns></returns>
        public static double MaximumCommonMantissa(double d1, double d2)
        {
            if (d1 == 0.0 || d2 == 0.0)
                return 0.0;

            DoubleBits db1 = new DoubleBits(d1);
            DoubleBits db2 = new DoubleBits(d2);

            if (db1.Exponent != db2.Exponent)
                return 0.0;

            int maxCommon = db1.NumCommonMantissaBits(db2);
            db1.ZeroLowerBits(64 - (12 + maxCommon));
            return db1.Double;
        }