23.11.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

}<br />

}<br />

System.out.println(Math.floor(d));<br />

System.out.println(Math.floor(f));<br />

This will produce the following result:<br />

-100.0<br />

-90.0<br />

-101.0<br />

-90.0<br />

Java – floor() Method<br />

Description<br />

The method floor gives the largest integer that is less than or equal to the argument.<br />

Syntax<br />

This method has the following variants:<br />

double floor(double d)<br />

double floor(float f)<br />

Parameters<br />

Here is the detail of parameters:<br />

<br />

A double or float primitive data type.<br />

Return Value<br />

<br />

Example<br />

This method returns the largest integer that is less than or equal to the argument.<br />

Returned as a double.<br />

public class Test{<br />

public static void main(String args[]){<br />

double d = -100.675;<br />

float f = -90;<br />

95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!