diff src/main/java/de/intevation/lada/util/data/MathUtil.java @ 944:af0883b73551

Fix typo.
author Tom Gottfried <tom@intevation.de>
date Wed, 18 May 2016 14:12:41 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/util/data/MathUtil.java	Wed May 18 14:12:41 2016 +0200
@@ -0,0 +1,30 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.util.data;
+
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
+
+/**
+ * Utilities for calculations
+ *
+ */
+public class MathUtil {
+
+    public static final MathContext ROUNDING_CONTEXT = new MathContext(3,
+        RoundingMode.HALF_EVEN);
+
+    public static Double roundDoubleToThree(Double value) {
+        if (value == null) {
+            return null;
+        }
+        return BigDecimal.valueOf(value).round(ROUNDING_CONTEXT).doubleValue();
+    }
+
+}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)