Java ceil() 方法

Java 教程 · 2019-02-08 11:42:53

ceil() 方法可对一个数进行上舍入,返回值大于或等于给定的参数。

语法

该方法有以下几种语法格式:

double ceil(double d)

double ceil(float f)

参数

  • double 或 float 的原生数据类型。

返回值

返回 double 类型,返回值大于或等于给定的参数。

实例

public class Test{ public static void main(String args[]){ double d = 100.675; float f = -90; System.out.println(Math.ceil(d)); System.out.println(Math.ceil(f)); System.out.println(Math.floor(d)); System.out.println(Math.floor(f)); } }

编译以上程序,输出结果为:

101.0
-90.0
100.0
-90.0

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

jQuery

jQuery

Earle Castledine、Craig Sharkie / SitePoint / 2010-02-28 / USD 39.95

jQuery: Novice to Ninja is a compilation of best-practice jQuery solutions to meet the most challenging JavaScript problems. In this question-and-answer book on jQuery, you'll find a cookbook of ready......一起来看看 《jQuery》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试