黑马程序员技术交流社区
标题:
关于类型转换的问题
[打印本页]
作者:
mls123456
时间:
2015-7-5 20:58
标题:
关于类型转换的问题
byte,short,char 直接转换为int ,为什么 float运算不转换为double呢?
public class BianLianmls {
public static void main(String[] args) {
byte b1= 1;
b1= (byte)(b1+1);//b1=b1+1
b1+=1;
float d = 3;
float d1=d+1;
System.out.println(d);
}
}
作者:
发抖的_DtYJA
时间:
2015-7-5 21:37
什么类型转换啊
作者:
鹰隼展翼
时间:
2015-7-5 21:55
float和byte它们一样在计算时也是先转换成int型在进行计算,float范围>int范围,不会损失精度
作者:
3307747472
时间:
2015-7-6 16:54
赞赞赞赞赞赞赞赞赞赞赞
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2