public static double floor(double a)
Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. Special cases:
?If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
?If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
Parameters:aReturns:the largest (closest to positive infinity) floating-point value that is not greater than the argument and is equal to a mathematical integer.
Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer. Special cases:
?If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
?If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
Parameters:aReturns:the largest (closest to positive infinity) floating-point value that is not greater than the argument and is equal to a mathematical integer.
解决方案 »
- NEW开辟内存的问题,能自动销毁吗,机制是什么
- gcj和openjdk都是GPL的Java实现,区别在哪里?
- 电子邮件自动服务系统实施方案
- 关于fianlize的问题,搞不懂
- java静态方法和非静态方法有什么不同?
- 使用数字签名,可以访问文件,但是还是没有权限使用录音
- 想买本J2EE的入门书籍,大家推荐一本
- 大部分的程序都是模块化的,只需要知道方法和调用对象,那么在程序学习中,学习那些基本的数据算法有意义吗?
- 提问兼散专家分:请问DefaultCellEditor类如何使用?
- 朋友帮个忙::在JTree中用model.removeNodeFromParent和model.reload()两个方法为何都没有用??要设置什么或者其它???
- (高分)急死了:视频音频数据传送回放问题
- eclipse 里有servlet吗,如没有,在什么地方又可下载?
Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer. Special cases:
?If the argument value is already equal to a mathematical integer, then the result is the same as the argument.
?If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
?If the argument value is less than zero but greater than -1.0, then the result is negative zero.
Note that the value of Math.ceil(x) is exactly the value of -Math.floor(-x).Parameters:aReturns:the smallest (closest to negative infinity) floating-point value that is not less than the argument and is equal to a mathematical integer.
Returns the closest int to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type int. In other words, the result is equal to the value of the expression: (int)Math.floor(a + 0.5f)Special cases:
?If the argument is NaN, the result is 0.
?If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.
?If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.
Parameters:a - a floating-point value to be rounded to an integer.Returns:the value of the argument rounded to the nearest int value.See Also:Integer.MAX_VALUE, Integer.MIN_VALUE
roundpublic static long round(double a)
Returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long. In other words, the result is equal to the value of the expression: (long)Math.floor(a + 0.5d)Special cases:
?If the argument is NaN, the result is 0.
?If the argument is negative infinity or any value less than or equal to the value of Long.MIN_VALUE, the result is equal to the value of Long.MIN_VALUE.
?If the argument is positive infinity or any value greater than or equal to the value of Long.MAX_VALUE, the result is equal to the value of Long.MAX_VALUE.
Parameters:a - a floating-point value to be rounded to a long.Returns:the value of the argument rounded to the nearest long value.See Also:Long.MAX_VALUE, Long.MIN_VALUE
round(a) 返回离a最接近的整数,返回类型int
ceil(a) 返回大于a的最小整数,返回类型double
如:
System.out.println(Math.floor(2.36)); //2.0
System.out.println(Math.round(2.56)); //3
System.out.println(Math.round(-2.36)); //-2
System.out.println(Math.ceil(2.56)); //3.0
System.out.println(Math.round(-2.56)); //-3
System.out.println(Math.round(2.36)); //2
System.out.println(Math.ceil(-2.56)); //-2.0