Comparing the values of two generic Numbers

后端 未结 12 1824
小鲜肉
小鲜肉 2020-11-27 04:48

I want to compare to variables, both of type T extends Number. Now I want to know which of the two variables is greater than the other or equal. Unfortunately I

12条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 05:14

    System.out.println(new BigDecimal(0.1d).toPlainString());
    System.out.println(BigDecimal.valueOf(0.1d).toPlainString());
    System.out.println(BigDecimal.valueOf(0.1f).toPlainString());
    System.out.println(Float.valueOf(0.1f).toString());
    System.out.println(Float.valueOf(0.1f).doubleValue());
    

提交回复
热议问题