From e27fdf2322d691d8d795fa4a667c5363e0f8d5e2 Mon Sep 17 00:00:00 2001
From: ChenJiaHe <763432473@qq.com>
Date: 星期四, 08 四月 2021 15:40:09 +0800
Subject: [PATCH] 新增double取多少小数点方法

---
 src/main/java/com/hx/util/NumberUtil.java |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/NumberUtil.java b/src/main/java/com/hx/util/NumberUtil.java
index 708ac35..27d25e0 100644
--- a/src/main/java/com/hx/util/NumberUtil.java
+++ b/src/main/java/com/hx/util/NumberUtil.java
@@ -337,4 +337,18 @@
         return str;
     }
 
+    /**Double绫诲瀷杞寲
+     * @param data 鏁版嵁
+     * @param digitNumber 淇濈暀澶氬皯浣嶅皬鏁�
+     * @return
+     */
+    public static Double getTypeDouble(Double data,Integer digitNumber) {
+        //鍒╃敤BigDecimal鏉ュ疄鐜板洓鑸嶄簲鍏�.淇濈暀涓�浣嶅皬鏁�
+        double result2 = new BigDecimal(data).setScale(digitNumber, BigDecimal.ROUND_HALF_UP).doubleValue();
+        //1浠h〃淇濈暀1浣嶅皬鏁�,淇濈暀涓や綅灏忔暟灏辨槸2
+        //BigDecimal.ROUND_HALF_UP 浠h〃浣跨敤鍥涜垗浜斿叆鐨勬柟寮�
+
+        return result2;
+    }
+
 }

--
Gitblit v1.8.0