dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Explore More Methods in the java.lang.Math Package

Check out this tip to understand more about the power of the java.lang.Math package.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


The java.lang.Math package is very powerful. Understand more methods in this package that are related to the Euler's number named e.

public class MathMethods
{
   public static void main(String args[])
   {
      MathMethods mathMethods = new MathMethods(); 
      mathMethods.proceed();
   }
   
   private void proceed()
   {
      //The methid Math.exp returns e^x, where x is the argument
      System.out.println(Math.exp(5));
      //The methid Math.expm1 returns e^x - 1, where x is the argument
      System.out.println(Math.expm1(5));
   }
}

/*

Expected output:



[root@mypc]# java MathMethods
148.4131591025766
147.4131591025766

*/

 

Visit the DevX Tip Bank

 



   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Thanks for your registration, follow us on our social networks to keep up-to-date