Java examples for java.lang:Math Value
Round down input value to nearest value of 10.
//package com.java2s; public class Main { /**/*from www . j a va 2 s . c om*/ * Round down input value to nearest value of 10. e.g. 323 returns 100. * @param value * @return */ public static int roundToNearestPowerOfTen(double value) { return (int) Math.pow(10, Math.floor(log10(value))); } /** * Calculates log base 10 of the specified value. */ public static double log10(double value) { return Math.log(value) / Math.log(10); } }