Math常见操作
package com.carlinfo.bigdata;
/**
* Math常见操作
*/
public class Ops1
{
public static void main(String[] args)
{
/**
*
* 进一
*/
double res = Math.ceil(1.1);
System.out.println(res);
/**
* 舍余
*/
double ret = Math.floor(1.8);
System.out.println(ret);
/**
* 强转(相当于舍余)
*/
double a = 1.5;
int i = (int) a;
System.out.println(i);
}
}
本文深入探讨了Java中Math类的常用操作,包括向上取整、向下取整和强制类型转换等核心概念,为开发者提供了实用的代码示例。
2472

被折叠的 条评论
为什么被折叠?



