Math.round(11.5) 等于多少? Math.round(-11.5)等于多少?
参考解答
- Math.round(11.5) 四舍五入结果为12
- Math.round(-11.5) 负数四舍五入选择较大的整数,结果为-11
Math中的舍入方法有:
方法 | 说明 |
---|---|
static double ceil(double a) | 返回大于等于a的最小数(整数部分保留,小数部分舍去) |
static double floor(double a) | 返回小于等于a的最大数(整数部分保留,小数部分舍去) |
static long round(double a) | 返回四舍五入的long整数 |
static int round(double a) | 返回四舍五入的int整数 |