首页 > 代码库 > Java BigDecimal

Java BigDecimal

 

 

 1 package com.helen.test; 2  3 import java.math.BigDecimal; 4  5 public class TestBigDecimal { 6  7     /** 8      * @param args 9      */10     public static void main(String[] args) {11         12         double d1=0.31125;13         double d2=3;14         System.out.println(d1*d2); //0.933750000000000115         16         float f1=0.31125f;17         float f2=3;18         System.out.println(f1*f2); //0.9337500319         20         BigDecimal b1=new BigDecimal(0.31125+"");21         BigDecimal b2=new BigDecimal(3);22         BigDecimal b3= b1.multiply(b2);23 24         System.out.println(b3); //0.9337525         26         27         28 29     }30 31 }

 

Java BigDecimal