最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
android 把float转换成Int的实例讲解
时间:2022-06-25 22:54:46 编辑:袖梨 来源:一聚教程网
1、采用强转的方式
float a = 1.1L; //定义一个float型变量,变量名为a,值为1.1,L表示是浮点型 int b = (int)a;//用(int)强制转换为整型b
2、采用Math.round方式
float a = 1.1L; //定义一个float型变量,变量名为a,值为1.1,L表示是浮点型 int b = Math.round(a);//采用round方式转换为整型