Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# how to calculate e ^3 using Math.pow

sarah sturgeon
Greenhorn
Posts: 11
Hi everybody

I want to calculate e^3 using Math.pow

I understand that I can do the following :

Math.pow (2.718,3) where 2.718 is the value of " e"

Is there anyway i can use " e" rather than its value for better accuracy e.g Math.pow( e,3) ?

Thanks and have a great a weekend.

Paul Clapham
Sheriff
Posts: 21443
33
• 2
Indeed there is. Check out the documentation for the Math class and you should find it near the top.

Campbell Ritchie
Sheriff
Posts: 50702
83
. . . and if you go through the whole of the Math class, you find how you can dispense with the value of e altogether.

Nelson Jumbo
Greenhorn
Posts: 4
You can use this e.g:
System.out.println( Math.E+"");

Darryl Burke
Bartender
Posts: 5148
11
1. How does that help to get e^3?
2. To print the value of Math.E, it's unnecessary to concatenate it to an empty String.

Nelson Jumbo
Greenhorn
Posts: 4
Math.pow(Math.E,3);

is working fine for me.

Mike Simmons
Ranch Hand
Posts: 3090
14
. . . and if you go through the whole of the Math class, you find how you can dispense with the value of e altogether.

Campbell Ritchie
Sheriff
Posts: 50702
83
Mike Simmons wrote:. . . and if you go through the whole of the Math class, you find how you can dispense with the value of e altogether.
There is something familiar about that post, but I can't quite put my finger on it