Java Double Number Round round(double number, double multiplier)

Here you can find the source of round(double number, double multiplier)

Description

Rounds the number of decimal places based on the given multiplier.
e.g.
Input: 17.5245743
multiplier: 1000
Output: 17.534
multiplier: 10
Output 17.5

License

Open Source License

Parameter

Parameter Description
number The input value.
multiplier The multiplier.

Return

The input rounded to a number of decimal places based on the multiplier.

Declaration

public static double round(double number, double multiplier) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/* w  ww  .  ja v a2s  . c om*/
     * Rounds the number of decimal places based on the given multiplier.<br>
     * e.g.<br>
     * Input: 17.5245743<br>
     * multiplier: 1000<br>
     * Output: 17.534<br>
     * multiplier: 10<br>
     * Output 17.5<br><br>
     *
     * @param number The input value.
     * @param multiplier The multiplier.
     * @return The input rounded to a number of decimal places based on the multiplier.
     */
    public static double round(double number, double multiplier) {
        return Math.round(number * multiplier) / multiplier;
    }
}

Related

  1. round(double num, int bit)
  2. round(double num, int decimal)
  3. round(double num, int numDecs, boolean rawFactor)
  4. round(double num, int precision)
  5. round(double number)
  6. round(double number, int decimal)
  7. round(double number, int digit)
  8. round(double number, int digits)
  9. round(double number, int places)