Java Double Number Round roundAwayFromZero(double num)

Here you can find the source of roundAwayFromZero(double num)

Description

round Away From Zero

License

GNU General Public License

Declaration

public static double roundAwayFromZero(double num) 

Method Source Code

//package com.java2s;
/** This class is a PanelLeft factory, creating all panels based on the
 * contents of the panels.xml file./* ww w  .  j  a  v a  2  s.c  om*/
 *
 * Last Updated:  May 25, 2011
 *
 * by Rick C. Hodgin
 * Cossatot Analytics Laboratories, LLC. (Cana Labs)
 *
 * (c) Copyright Cana Labs.
 * Free software licensed under the GNU GPL2.
 *
 * @author Rick C. Hodgin
 * @version 1.0.0
 *
 * Change history:
 *   2011-05-25 - 1.0.0 - Initial release
 *
 */

public class Main {
    public static double roundAwayFromZero(double num) {
        if (num >= 0.0)
            return (Math.round(num + 0.49999999999999)); // Normal positive rounding
        else
            return (Math.round(num - 0.49999999999999)); // Negative rounding
    }
}

Related

  1. round_nearestmultipleof5(double value)
  2. roundAndScale(double startValue, int places)
  3. roundAngle(double a, long n)
  4. roundAtDecimals(double number, int deci)
  5. roundAway(double d)
  6. roundBig(double d)
  7. roundDec(float num, int dec)
  8. roundDecimal(Double value)
  9. roundDecimal(double x, int d)