Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java ceil() Method

Java ceil() Method

Java Number ClassThe Java Number class


The ceil() method rounds a number up; the return value is greater than or equal to the given argument, and the type is double.

Syntax

This method has the following syntax formats:



double ceil(double d)



double ceil(float f)

Parameters

Return Value

Returns a double; the return value is greater than or equal to the given argument.

Example

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

)

)

;

}

}

Compile the above program; the output is:



101.0

-90.0

100.0

-90.0


Java Number ClassThe Java Number class