Exemple #1
0
        public static int ComputeQuadLevel(Envelope env)
        {
            double dx    = env.Width;
            double dy    = env.Height;
            double dMax  = dx > dy ? dx : dy;
            int    level = DoubleBits.Exponent(dMax) + 1;

            return(level);
        }
Exemple #2
0
        /// <summary>
        /// Computes the exponent for the largest power of two
        /// less than the absolute value of the argument.
        /// In other words, finds the value n such that
        /// 2&#136;n &lt;= abs(num) &lt; 2&#136;(n+1)
        /// </summary>
        /// <param name="num"></param>
        /// <returns>The exponent.</returns>
        public static int Exponent(double num)
        {
            num = Math.Abs(num);
            double log  = Math.Log(num);
            double log2 = log / LOG_2;
            int    exp  = (int)Math.Floor(log2);

            int exp2 = DoubleBits.Exponent(num);

            if (exp != exp2)
            {
                //System.out.println(DoubleBits.toBinaryString(num));
                //System.out.println(num + " pow2 mismatch: " + exp + "   DoubleBits: " + exp2);
                double pow2exp  = DoubleBits.PowerOf2(exp);
                double pow2exp2 = DoubleBits.PowerOf2(exp2);
                //System.out.println(pow2exp + "   pow2exp2 = " + pow2exp2);
            }
            return(exp);
        }