コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="level"></param>
        /// <param name="itemEnv"></param>
        private void ComputeKey(int level, IEnvelope itemEnv)
        {
            double quadSize = DoubleBits.PowerOf2(level);

            pt.X = Math.Floor(itemEnv.MinX / quadSize) * quadSize;
            pt.Y = Math.Floor(itemEnv.MinY / quadSize) * quadSize;
            env.Init(pt.X, pt.X + quadSize, pt.Y, pt.Y + quadSize);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="env"></param>
        /// <returns></returns>
        public static int ComputeQuadLevel(IEnvelope env)
        {
            double dx    = env.Width;
            double dy    = env.Height;
            double dMax  = dx > dy ? dx : dy;
            int    level = DoubleBits.GetExponent(dMax) + 1;

            return(level);
        }
コード例 #4
0
 /// <summary>
 /// This computes the number of common most-significant bits in the mantissa.
 /// It does not count the hidden bit, which is always 1.
 /// It does not determine whether the numbers have the same exponent - if they do
 /// not, the value computed by this function is meaningless.
 /// </summary>
 /// <param name="db"></param>
 /// <returns> The number of common most-significant mantissa bits.</returns>
 public int NumCommonMantissaBits(DoubleBits db)
 {
     for (int i = 0; i < 52; i++)
     {
         if (GetBit(i) != db.GetBit(i))
         {
             return(i);
         }
     }
     return(52);
 }
コード例 #5
0
        /// <summary>
        /// Computes whether the interval [min, max] is effectively zero width.
        /// I.e. the width of the interval is so much less than the
        /// location of the interval that the midpoint of the interval cannot be
        /// represented precisely.
        /// </summary>
        public static bool IsZeroWidth(double min, double max)
        {
            double width = max - min;

            if (width == 0.0)
            {
                return(true);
            }
            double maxAbs         = Math.Max(Math.Abs(min), Math.Abs(max));
            double scaledInterval = width / maxAbs;
            int    level          = DoubleBits.GetExponent(scaledInterval);

            return(level <= MinBinaryExponent);
        }
コード例 #6
0
ファイル: DoubleBits.cs プロジェクト: DIVEROVIEDO/DotSpatial
        /// <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;
        }
コード例 #7
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);
            }

            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);
        }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static string ToBinaryString(double d)
        {
            DoubleBits db = new DoubleBits(d);

            return(db.ToString());
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public static int GetExponent(double d)
        {
            DoubleBits db = new DoubleBits(d);

            return(db.Exponent);
        }
コード例 #10
0
ファイル: DoubleBits.cs プロジェクト: DIVEROVIEDO/DotSpatial
 /// <summary>
 /// 
 /// </summary>
 /// <param name="d"></param>
 /// <returns></returns>
 public static string ToBinaryString(double d)
 {
     DoubleBits db = new DoubleBits(d);
     return db.ToString();
 }
コード例 #11
0
ファイル: DoubleBits.cs プロジェクト: DIVEROVIEDO/DotSpatial
 /// <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;
 }
コード例 #12
0
ファイル: DoubleBits.cs プロジェクト: DIVEROVIEDO/DotSpatial
 /// <summary>
 /// 
 /// </summary>
 /// <param name="d"></param>
 /// <returns></returns>
 public static int GetExponent(double d)
 {
     DoubleBits db = new DoubleBits(d);
     return db.Exponent;
 }
コード例 #13
0
ファイル: DoubleBits.cs プロジェクト: DIVEROVIEDO/DotSpatial
 /// <summary> 
 /// This computes the number of common most-significant bits in the mantissa.
 /// It does not count the hidden bit, which is always 1.
 /// It does not determine whether the numbers have the same exponent - if they do
 /// not, the value computed by this function is meaningless.
 /// </summary>
 /// <param name="db"></param>
 /// <returns> The number of common most-significant mantissa bits.</returns>
 public int NumCommonMantissaBits(DoubleBits db)
 {
     for (int i = 0; i < 52; i++)
     {            
     if (GetBit(i) != db.GetBit(i))
         return i;
     }
     return 52;
 }