How to Do Exponentials in Java

When you raise a number to a separate number, called the "exponent," you perform an exponential operation on the original number. This is a basic mathematical operation, and is natively supported by various programming languages, including Java.

Instructions

    • 1

      Open your Java program in your editor of choice.

    • 2

      Initialize your number variable -- "4" in this example -- by typing "int origNum = 4;" on a new line in the program.

    • 3

      Initialize your exponent -- "2" in this example -- by typing "int exponent = 2;" on a new line in the program.

    • 4

      Perform the exponential function and set the result equal to a new variable by typing "double expResult = pow(origNum,exponent);" on a new line in the program.

Related Searches:

References

Comments

Related Ads

Featured