944
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU GPL (v>=3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
|
7 */ |
|
8 package de.intevation.lada.util.data; |
|
9 |
|
10 import java.math.BigDecimal; |
|
11 import java.math.MathContext; |
|
12 import java.math.RoundingMode; |
|
13 |
|
14 /** |
|
15 * Utilities for calculations |
|
16 * |
|
17 */ |
|
18 public class MathUtil { |
|
19 |
|
20 public static final MathContext ROUNDING_CONTEXT = new MathContext(3, |
|
21 RoundingMode.HALF_EVEN); |
|
22 |
|
23 public static Double roundDoubleToThree(Double value) { |
|
24 if (value == null) { |
|
25 return null; |
|
26 } |
|
27 return BigDecimal.valueOf(value).round(ROUNDING_CONTEXT).doubleValue(); |
|
28 } |
|
29 |
|
30 } |