quote:Original post by InTheSackMan
Not exactly sure if this helps but since this is on a programming forum, you don't need to calculate it past a float or a double's accuracy because your just going to lose it anyways. e is irrational and calculating it is slow. I would just make a double equal to as much of e as it could hold and use that.
If you want a good equation to calculate it to a specific accuracy while hiding all the calculus it is:
e = (1 + 1/x)^x
The higher x is the closer you get to a value for e.
You're going to have to cut off the accuracy at some point anyways, unless your doing something really advanced which I'm assuming your not since you don't know calculus yet ; )
Good luck!
Either this or the taylor series is useful to calculate e if you want. With the taylor series it's simple to determine if you've achieved the number of decimal places you want though.
If you want to be really picky, you can state that e come from this process:
define ∫ 1->inf dx/x = ln x,
then e is the value for which ln x = 1
all other "definitions" are really results of the true definition
but that's really too picky for game development
in reality, use const double E = 2.718281828 and be done with it
if you need to find e^x in a game(first ask why), then use the taylor series. it's the easiest way to do the power.
EDIT: Not that I prefer or even like this picky definiton at all...see 2 posts down
[edited by - etothex on May 11, 2004 4:49:46 AM] [edited by - etothex on May 11, 2004 5:27:26 AM]