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

Java floor() Method

Java floor() Method

Java Number ClassThe Java Number class


The floor() method rounds a number down and returns the largest integer that is less than or equal to the given argument.

Syntax

This method has the following syntax formats:



double floor(double d)



double floor(float f)

Parameters

Return Value

Returns double data that is less than or equal to the given argument.

Example

Example

public

class

Test

{

public

static

void

main

(

String

args

[

]

)

{

double

d

=

100

.675

;

float

f

= -

90

;

System

.

out

.

println

(

Math

.

floor

(

d

)

)

;

System

.

out

.

println

(

Math

.

floor

(

f

)

)

;

System

.

out

.

println

(

Math

.

ceil

(

d

)

)

;

System

.

out

.

println

(

Math

.

ceil

(

f

)

)

;

}

}

Compile the above program; the output is:



100.0

-90.0

101.0

-90.0


Java Number ClassThe Java Number class