JAVA中的除法运算

int a=4;
int b=3;
float c = (float) a/b;
System.out.print(c);
//输出:1

如果要的到精确的结果,要用下面的方法

int a=4;
int b=3;
float c = (float) a/(float) b;
System.out.print(c);
//输出:1.3333334
posted @ 2009-11-16 16:53  弹着钢琴设计  阅读(39901)  评论(0编辑  收藏  举报