标签:targe str mat oid static out test www ati
https://www.jianshu.com/p/4679618fd28c 这篇文章介绍的比较仔细。
1 package com.cy.test.math; 2 3 4 import java.math.BigDecimal; 5 6 public class TestCompareDouble { 7 8 /** 9 * 比较两个double类型数的大小 10 * @param args 11 */ 12 public static void main(String[] args) { 13 double targetScore = Double.parseDouble("0.5"); 14 double score = 0.500001; 15 16 BigDecimal score1 = new BigDecimal(String.valueOf(targetScore)); 17 BigDecimal score2 = new BigDecimal(String.valueOf(score)); 18 System.out.println(score2.doubleValue()); 19 20 if(score2.compareTo(score1) >= 0){ 21 System.out.println("score2大于等于score1"); 22 } 23 } 24 }
标签:targe str mat oid static out test www ati
原文地址:https://www.cnblogs.com/tenWood/p/11984090.html