Here you can find the source of roundValue(final double value)
Parameter | Description |
---|---|
value | to round up |
public static final double roundValue(final double value)
//package com.java2s; /*//from w w w . j a va 2 s.com * Corsen development code * * This code may be freely distributed and modified under the * terms of the GNU General Public Licence version 2 or later. This * should be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/licenses/gpl-2.0.txt * * Copyright for this code is held jointly by the microarray platform * of the ?cole Normale Sup?rieure and the individual authors. * These should be listed in @author doc comments. * * For more information on the Corsen project and its aims, * or to join the Corsen google group, visit the home page * at: * * http://transcriptome.ens.fr/corsen * */ public class Main { /** * Round up a double value * @param value to round up * @return a round up value */ public static final double roundValue(final double value) { return roundValue(value, 0.00000000000001); } /** * Round up a double value * @param value to round up * @param threshold the threshold * @return a round up value */ public static final double roundValue(final double value, final double threshold) { final double rInt = Math.rint(value); if (Math.abs(value - rInt) < threshold) return rInt; return value; } /** * Round up a float value * @param value to round up * @return a round up value */ public static final float roundValue(final float value) { return roundValue(value, 0.00001f); } /** * Round up a float value * @param value to round up * @param threshold the threshold * @return a round up value */ public static final float roundValue(final float value, final float threshold) { final float rInt = (float) Math.rint(value); if (Math.abs(value - rInt) < threshold) return rInt; return value; } }