Java program to calculate pi
The Math.floorDiv() method divides one integer ( int or long) by another, and rounds the result down to the nearest integer value.
![java program to calculate pi java program to calculate pi](https://onurdesk.com/wp-content/uploads/2020/11/image-17-1024x150.png)
Java program to calculate pi code#
Here is a Math.floor() Java example: double floor = Math.floor(7.343) // floor = 7.0Īfter executing this Java code the ceil variable will contain the value 8.0. The rounded value is returned as a double. The Math.floor() function rounds a floating point value down to the nearest integer value. Here is a Math.ceil() Java example: double ceil = Math.ceil(7.343) // ceil = 8.0Īfter executing this Java code the ceil variable will contain the value 8.0. The Math.ceil() function rounds a floating point value up to the nearest integer value. Which of these methods are called depends on the type of the parameter passed to the Math.abs() method. The Math.abs() method is overloaded in 4 versions: Math.abs(int) Here are two Math.abs() method examples: int abs1 = Math.abs(10) // abs1 = 10 If the parameter value is negative, the negative sign is removed and the positive value corresponding to the negative value without sign is returned. The absolute value is the positive value of the parameter. The Math.abs() function returns the absolute value of the parameter passed to it. These basic math functions of the Java Math class will be covered in the following sections.
![java program to calculate pi java program to calculate pi](https://ecomputernotes.com/images/Area-of-Circle.jpg)
The contains a set of basic math functions for obtaining the absolute value, highest and lowest of two values, rounding of values, random values etc.