tom@948: /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz tom@948: * Software engineering by Intevation GmbH tom@948: * tom@948: * This file is Free Software under the GNU GPL (v>=3) tom@948: * and comes with ABSOLUTELY NO WARRANTY! Check out tom@948: * the documentation coming with IMIS-Labordaten-Application for details. tom@948: */ tom@948: package de.intevation.lada.util.data; tom@948: tom@948: import java.math.BigDecimal; tom@948: import java.math.MathContext; tom@948: import java.math.RoundingMode; tom@948: tom@948: /** tom@948: * Utilities for calculations tom@948: * tom@948: */ tom@948: public class MathUtil { tom@948: tom@948: public static final MathContext ROUNDING_CONTEXT = new MathContext( tom@948: 3, RoundingMode.HALF_EVEN); tom@948: tom@948: public static Double roundDoubleToThree(Double value) { tom@948: if (value == null) { tom@948: return null; tom@948: } tom@948: return BigDecimal.valueOf(value).round(ROUNDING_CONTEXT).doubleValue(); tom@948: } tom@948: tom@948: }