java lang StrictMath Class - StrictMath Class in Java
java.lang.StrictMath Class
StrictMath Class in Java
The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
The Java math library is defined with respect to fdlibm version 5.3. Where fdlibm provides more than one definition for a function (such as acos), use the "IEEE 754 core function" version (residing in a file whose name begins with the letter e). The methods which require fdlibm semantics are sin, cos, tan, asin, acos, atan, exp, log, log10, cbrt, atan2, pow, sinh, cosh, tanh, hypot, expm1, and log1p.
In this Java StrictMath class tutorial you can learn how to use StrictMath class. You need not to create instance for StrictMath class. Because all the methods in StrictMath class are static methods. All the static methods are called with the class name.
What is java.lang.StrictMath in Java ?
The StrictMath is a class in Java . This StrictMath class is available in java.lang package . The StrictMath class contains methods for performing basic numeric operations such as the elementary exponential , logarithm , square root , and trigonometric functions .
What is the package name which contains StrictMath class ?
The Java package that contains the StrictMath class is StrictMath . This class is used to perform almost all basic numeric operations . It is defined as public final class StictMath .
Do I need to import StrictMath in Java ?
Since StrictMath class is in the java.lang package , the StrictMath class does not need to be imported . However , in programs extensively utilizing these functions , a static import can be used . There is no need to explicitly import java.lang.StrictMath as its imported implicitly . All its methods are static . This explanation also useful for how to import java.lang.StrictMath ? .
java.lang.StrictMath Class Example
/* Java StrictMath Class Example Save with file name StrictMathExample.java */ public class StrictMathExample { public static void main(String args[]) { // IF THE VALUE IS NEGITIVE IT RETURNS POSITIVE VALUE System.out.println("Absolute : " + StrictMath.abs(-100.50)); // IT INCREASE THE VALUE TO NEAREST INTEGER System.out.println("ceil : " + StrictMath.ceil(100.55)); // IT DECREASE THE VALUE TO NEAREST INTEGER System.out.println("floor : " + StrictMath.floor(100.55)); // IT RETURNS MAX NUMBER WITH IN THE GIVEN NUMBERS System.out.println("max : " + StrictMath.max(100,200)); // IT RETURNS MIN NUMBER WITH IN THE GIVEN NUMBERS System.out.println("min : " + StrictMath.min(100,200)); // IT RETURNS RANDOM NUMBER System.out.println("random : " + StrictMath.random()); // IT RETURNS WITHOUT FLOATING POINT System.out.println("round : " + StrictMath.round(100.75)); // IT RETURNS SQUARE ROOT System.out.println("sqrt : " + StrictMath.sqrt(2)); // IT RETURNS PI VALUE (22/7) System.out.println("PI : " + StrictMath.PI); // RETURNS NATURAL LOGARITHM System.out.println("log : " + StrictMath.log(10.55)); // RETURNS BASE 10 LOGARITHM System.out.println("log10 : " + StrictMath.log10(10.55)); // RETURNS NATURAL LOGARITHM OF SUM OF THE ARGUMENT AND 1 System.out.println("log1p : " + StrictMath.log1p(10.55)); } }
Following Java StrictMath class example you can learn how to use trigonometric functions in java.
java.lang.StrictMath Class Example 2
/* Java StrictMath Class Example Save with file name StrictMathExample2.java */ public class StrictMathExample2 { public static void main(String args[]) { // RETURNS ARC COSINE System.out.println("acos : " + StrictMath.acos(0.4)); // RETURNS ARC SINE System.out.println("asin : " + StrictMath.asin(0.4)); // RETURNS ARC TANGENT VALUE System.out.println("atan : " + StrictMath.atan(45)); // RETURNS COSINE OF AN ANGLE System.out.println("cos : " + StrictMath.cos(45)); // RETURNS HYPERBOLIC COSINE System.out.println("cosh : " + StrictMath.cosh(45)); // RETURNS SINE OF AN ANGLE System.out.println("sin : " + StrictMath.sin(45)); // RETURNS HYPERBOLIC SINE System.out.println("sinh : " + StrictMath.sinh(45)); // RETURNS TANGENT OF AN ANGLE System.out.println("tan : " + StrictMath.tan(45)); // RETURNS HYPERBOLIC TANGENT System.out.println("tanh : " + StrictMath.tanh(45)); // RETURNS DEGREES System.out.println("toDegrees : " + StrictMath.toDegrees(45)); // RETURNS RADIANS System.out.println("toRadians : " + StrictMath.toRadians(45)); } }