

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get floor value of a number using Math.floor in Java
To get the floor value of a number, we use the java.lang.Math.floor() method. The Math.floor() method returns the largest (closest to positive infinity) double value which is less than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.
Declaration - The java.lang.Math.floor() method is declared as follows −
public static double floor(double a)
Let us see a program to get the floor value of a number in Java.
Example
import java.lang.Math; public class Example { public static void main(String[] args) { // declaring and initialising some double values double a = -100.01d; double b = 34.6; double c = 600; // printing their floor values System.out.println("Floor value of " + a + " = " + Math.floor(a)); System.out.println("Floor value of " + b + " = " + Math.floor(b)); System.out.println("Floor value of " + c + " = " + Math.floor(c)); } }
Output
Floor value of -100.01 = -101.0 Floor value of 34.6 = 34.0 Floor value of 600.0 = 600.0
- Related Questions & Answers
- Get ceiling value of a number using Math.ceil in Java
- Get exponential value of a number using Math.exp in Java
- Get floor key from NavigableMap in Java
- Get square root of a number using Math.sqrt in Java
- Math.floor() function in JavaScript
- Math.Floor() Method in C#
- How to get a number value of a string in Javascript?
- Get natural logarithm value using Math.log in Java
- math.floor() function in Lua programming
- How to get the absolute value of a number in JavaScript?
- Get the hyperbolic cosine of a given value in Java
- Get the hyperbolic sine of a given value in Java
- Get the base 10 logarithm of a value in Java
- Get the hyperbolic tangent of a given value in Java
- Get the arc tangent of a given value in Java
Advertisements