Java Number Round roundHalfAway(double d)

Here you can find the source of roundHalfAway(double d)

Description

round Half Away

License

Open Source License

Declaration

public static double roundHalfAway(double d) 

Method Source Code

//package com.java2s;

public class Main {
    public static double roundHalfAway(double d) {
        if (d < 0) {
            d = Math.ceil(d - 0.5);
        } else if (d > 0) {
            d = Math.floor(d + 0.5);
        }//ww  w. j  av a  2s. c  om
        return d;
    }
}

Related

  1. roundFloat(float value, int afterDecimalPoint)
  2. roundFloatToPlace(float f, int place)
  3. roundFloatToUnitInverse(final float graphValue, final float graphUnit)
  4. roundFormat(final int numPrec, final double number)
  5. RoundFullUp(double d)
  6. RoundHalfUp(double d)
  7. roundIfClose(double val)
  8. Rounding(double d, int i)
  9. rounding(double val)