short 和 float
来源:互联网 发布:linux optargs 编辑:程序博客网 时间:2024/05/16 12:49
1.short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?
short s1 = 1; s1 = s1 +1;有错,; //short s1 = 1;(此处已经将s1转换为int 型);s1是short型,s1+1是int型,不能显式转化为short型。可修改为s1 =(short)(s1 + 1) 。
short s1 = 1; s1 += 1正确。si +=a(a为任意数字)的定义为s1=((T)(s1+a)),T为a的类型。
2.float型float f=3.4是否正确?
答:不正确。精度不准确,应该用强制类型转换,如下所示:float f=(float)3.4
- short 和 float
- short float double
- short int、long、float、double
- short,int,float,long,double
- char、int、short、float等数据类型的最大值和最小值大全
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- JAVA 各种数值类型最大值和最小值 Int, short, char, long, float,&nbs
- JAVA 各种数值类型最大值和最小值 Int, short, char, long, float,&nbs
- java Byte和各数据类型(short,int,long,float,double)之间的转换
- JAVA 各种数值类型最大值和最小值 Int, short, char, long, float,&nbs
- JAVA 各种数值类型最大值和最小值 Int, short, char, long, float,&nbs
- JAVA 各种数值类型最大值和最小值 Int, short, char, long, float,&nbs
- byte short int long float double
- char、short、int、long、char、float、double
- char short int long float double
- byte char short long float double理解
- short和long
- byte[]和short[]
- makefile实例
- POJ 3258 River Hopscotch
- Linux 与 Linux服务器之间文件传输方式之SCP
- Fiddler使用详解
- 深度学习(Deep Learning,DL)的相关资料总结
- short 和 float
- GDB调试精粹及使用实例
- WIN7 & V.C60 & Visual_AssistX
- target is null for setProperty(null, "x", [Ljava.lang.String;@b0c40e)错误异常
- android通知
- NSTimer的用法
- C++中 for(; ;) 循环语句
- 给Label随机分配背景颜色
- Oralce如何避免no data found