Java Double Number Round round(double a, double precision)

Here you can find the source of round(double a, double precision)

Description

Mathematically rounds a number with a defined precision.

License

Open Source License

Parameter

Parameter Description
a Value
precision Precision

Return

Rounded value

Declaration

public static double round(double a, double precision) 

Method Source Code

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

public class Main {
    /**/*  w w  w.j a  v  a2  s  .  com*/
     * Mathematically rounds a number with a defined precision.
     *
     * @param a         Value
     * @param precision Precision
     * @return Rounded value
     */
    public static double round(double a, double precision) {
        if (precision == 0.0) {
            return 0.0;
        }
        return Math.round(a / precision) * precision;
    }
}

Related

  1. getRatioString(double n, double d)
  2. round(double a)
  3. Round(double a)
  4. round(double a)
  5. round(double a, int cutOfDigits)
  6. round(double a, int decimal)
  7. round(double a, int rounding_style)
  8. round(double amount)