Java Double Number Round round(double val)

Here you can find the source of round(double val)

Description

Our own implementation of Math.round due to difference between java 1.6 and 1.7 implementations See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6430675">Java bug 6430675</a> Using java 1.6 implementation of Math.round defined as floor of 0.5d plus value.

License

Open Source License

Parameter

Parameter Description
val value to round

Return

rounded value

Declaration

public static long round(double val) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  ww  .  j av  a2 s .  com
     * Our own implementation of Math.round due to difference between java 1.6 and 1.7 implementations
     * See <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6430675">Java bug 6430675</a>
     *
     * Using java 1.6 implementation of Math.round
     * defined as floor of 0.5d plus value.
     * @param val value to round
     * @return rounded value
     */
    public static long round(double val) {
        return (long) Math.floor(val + 0.5d);
    }
}

Related

  1. round(double Rpred[][])
  2. Round(double Rval, int Rpl)
  3. round(double toRound)
  4. round(double v)
  5. round(double v, int precision)
  6. round(double val)
  7. round(double val)
  8. round(double val, int decimalHouses)
  9. round(double val, int decimalPlaces)