Java Number Round roundToNearestPowerOfTen(double value)

Here you can find the source of roundToNearestPowerOfTen(double value)

Description

Round down input value to nearest value of 10.

License

LGPL

Declaration

public static double roundToNearestPowerOfTen(double value) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/*  ww w . j  a v a2 s.co m*/
     * Round down input value to nearest value of 10. e.g. 323 returns 100. 
     */
    public static double roundToNearestPowerOfTen(double value) {
        return 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);
    }
}

Related

  1. roundToNearestInterval(int i, int j)
  2. roundToNearestK(float v, int k)
  3. roundToNearestMultiple(double number, double multiple)
  4. roundToNearestMultipleOf(final long num, final long multipleOf)
  5. roundToNearestN(float value, float n)
  6. roundToNext(int val, int factor)
  7. roundToNextPowerOfTwo(int value)
  8. roundToNthDecimal(double number, int decimals)
  9. roundToNumDigits(double d, int n)