Latest web development tutorials

Java floor () method

Java Number classes Java Number classes


floor () method can be carried out on a number rounded down to return to the largest integer parameter set, the integer less than or equal to the given parameters.

grammar

This method has the following syntax:

double floor(double d)

double floor(float f)

parameter

  • Native data type double or float in.

return value

Returns an array of double type, is less than or equal to the given parameters.

Examples

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 classes Java Number classes