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

查看所有标签

Beginning XML with DOM and Ajax

Beginning XML with DOM and Ajax

Sas Jacobs / Apress / 2006-06-05 / USD 39.99

Don't waste time on 1,000-page tomes full of syntax; this book is all you need to get ahead in XML development. Renowned web developer Sas Jacobs presents an essential guide to XML. Beginning XML with......一起来看看 《Beginning XML with DOM and Ajax》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具