Home » Core Java » math

# math

## Math.random Java Example

In this article, we will explain Math.random method in Java through examples. Java provides us Math class, which includes methods with basic numeric operations such as logarithm, square root, etc. One of these methods is random(), which gives us a pseudorandom positive double number greater than or equal to 0.0 and less than 1.0 – [0.0, 1.0). You can learn ...

## Generate random Integer within given range

In this example we shall show you how to generate a random Integer within a given range, using random() method of Math. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. To generate a random Integer within a given range one should perform the following steps: Use random() method of ...

## Find floor value of a number

With this example we are going to demonstrate how to find the floor value of a number, using the floor(double a) API method of Math. Math API provides methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. In short, to find the floor value of a number you should: Use floor(double a) method ...

## Find natural logarithm value of a number

This is an example of how to find the natural logarithm value of a number, using the log(double a) method of Math. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Finding the natural logarithm value of a number implies that you should: Use log(double a) API method ...

## Find ceiling value of a number

In this example we shall show you how to find the ceiling value of a number, using the Math Class. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. To find the ceiling value of a number one should perform the following steps: Use ceil(double a) method of ...

## Round float and double numbers

With this example we are going to demonstrate how to round float and double numbers using round() method of Math. The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. In short, to round float and double numbers you should: Use round(float a) method to get the closest int to ...

## Java BigDecimal Example

In this article we will learn about the BigDecimal class in java. We will briefly discuss about the various methods available in the BigDecimal class. 1. What is BigDecimal? A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If zero or positive, the scale is the number of digits to the right of the ...

## Using Math Constants

In this example we shall show you how to get constant numbers using the Math Class. Apart from the methods for performing basic numeric operations such as square root, and trigonometric functions, the Math Class also has methods for getting the e, that is the base of the natural logarithms and the PI, that is the ratio of the circumference of ...