java 数据精确度

在开发与商城有关的项目时,因与金融打交道,所以需提高其精确度,java一般采用int类型,将单位设置为分,在前台调用需要转换为元时,在进行转换

public class Cycle {
public static final Long MEMBER_SHOP_APPLICATION_ALLOWED = (1L << 20);

public static void main(String[] args) {

System.out.println(Cycle.MEMBER_SHOP_APPLICATION_ALLOWED);
int a=89327;
Long b = (long)a/100;
Double c =(double) a/100;
System.out.println("long,"+b);
System.out.println("double,"+c);
}

}

上述案例输出结果为:

1048576
long,893
double,893.27

猜你喜欢

转载自www.cnblogs.com/qqzhulu/p/10182535.html