// Path: tileview/src/main/java/com/moagrius/utils/Maths.java
// public class Maths {
// 
//   public static final double LOG_2 = Math.log(2);
// 
//   public static double log2(int n) {
//     return Math.log(n) / LOG_2;
//   }
// 
//   public static int roundWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return Math.round(value / step) * step;
//   }
// 
//   public static int roundUpWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return (int) Math.ceil(value / step) * step;
//   }
// 
//   public static int roundDownWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return (int) Math.floor(value / step) * step;
//   }
// 
//   public static float divideSafely(int dividend, float divisor) {
//     if (dividend == 0 || divisor == 0) {
//       return 0;
//     }
//     return dividend / divisor;
//   }
// 
// }


import com.moagrius.utils.Maths;
package com.moagrius.tileview;


/**
 * ZOOM     PERCENT     SAMPLE
 * 0        100%        1
 * 1        50%         2
 * 2        25%         4
 * 3        12.5%       8
 * 4        6.25%       16
 * 5        3.125%      32
 * ...
 * handy math:
 * get percent from zoom: (1 >> zoom) / 1f (number of digits is precision, so (100 >> zoom) / 100f will give .012
 * get percent from sample: 1 / sample
 * get sample from zoom: 1 << zoom
 * get zoom from sample: Maths.log2(sample)
 */

public class Detail {

  public static int getZoomFromPercent(float percent) {
// Path: tileview/src/main/java/com/moagrius/utils/Maths.java
// public class Maths {
// 
//   public static final double LOG_2 = Math.log(2);
// 
//   public static double log2(int n) {
//     return Math.log(n) / LOG_2;
//   }
// 
//   public static int roundWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return Math.round(value / step) * step;
//   }
// 
//   public static int roundUpWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return (int) Math.ceil(value / step) * step;
//   }
// 
//   public static int roundDownWithStep(float value, int step) {
//     if (value == 0) {
//       return 0;
//     }
//     return (int) Math.floor(value / step) * step;
//   }
// 
//   public static float divideSafely(int dividend, float divisor) {
//     if (dividend == 0 || divisor == 0) {
//       return 0;
//     }
//     return dividend / divisor;
//   }
// 
// }


// Path: tileview/src/main/java/com/moagrius/tileview/Detail.java
import com.moagrius.utils.Maths;

package com.moagrius.tileview;


/**
 * ZOOM     PERCENT     SAMPLE
 * 0        100%        1
 * 1        50%         2
 * 2        25%         4
 * 3        12.5%       8
 * 4        6.25%       16
 * 5        3.125%      32
 * ...
 * handy math:
 * get percent from zoom: (1 >> zoom) / 1f (number of digits is precision, so (100 >> zoom) / 100f will give .012
 * get percent from sample: 1 / sample
 * get sample from zoom: 1 << zoom
 * get zoom from sample: Maths.log2(sample)
 */

public class Detail {

  public static int getZoomFromPercent(float percent) {
    return (int) Maths.log2((int) (1 / percent));