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

查看所有标签

New Dark Age

New Dark Age

James Bridle / Verso Books / 2018-7-17 / GBP 16.99

As the world around us increases in technological complexity, our understanding of it diminishes. Underlying this trend is a single idea: the belief that our existence is understandable through comput......一起来看看 《New Dark Age》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具