From deabcea411fbdcc11d5be1e13e507ae22d7e40d2 Mon Sep 17 00:00:00 2001 From: lzCodeGarden <3159933846@qq.com> Date: Mon, 18 Mar 2024 16:55:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=9B=B4=E6=94=B9=EF=BC=8C=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B7=AF=E5=BE=84=E6=8C=87=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/jyjz/xiaoyao/ocr/util/HashCompareUtil.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/util/HashCompareUtil.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/util/HashCompareUtil.java index b75ba45..f2ed6e0 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/util/HashCompareUtil.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/util/HashCompareUtil.java @@ -19,13 +19,22 @@ public class HashCompareUtil { n=n + 1; } } - return String.format("%.2f", 100.0 - n/64.0 * 100.0); + String formattedResult=""; + double c=100.0 - n/64.0 * 100.0; + if (c % 1 == 0) { + // 如果是整数,将小数位去除 + formattedResult = String.valueOf((int) c); + } else { + // 如果不是整数,保留两位小数 + formattedResult = String.format("%.2f", c); + } + return formattedResult; } public static void main(String[] args) { String a="1111111100000111000110110001101100110011001100000000000011110001"; - String b="1011111100000111000110110001101100110011001100000000000011110001"; + String b="1111111100000111000110110001101100110011001100000000000011110001"; long start = System.currentTimeMillis(); int ss=0; // for(int i=0;i<5000000;i++){