Real quick C++ question

Gooberlx2

Lifer
May 4, 2001
15,381
6
91
How do I get the value 'e'? (as in log 'e' x would be natural log of x)

Is it in the stl? 'cause I can't find it.

Thx
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
look in math.h it should be defined as a constant in there, im pretty sure pi is ther also.
 

20_MuleTeam_Borax

Senior member
Oct 9, 1999
681
0
0


<< yeah its E = 2.7182818284590452354
I looked on google and its in some math.h's
>>



It's not exactly that. e is a non-repeating decimal. it is defined as the limit of (1+n)^1/n as n approaches 0. there should be a much more accurate value defined for you somewhere.
 
Jun 18, 2000
11,218
781
126
Perhaps I'm not understanding something but the exp() function supposedly returns e^x where x is the value passed to the function. Couldn't you simply pass 1 to the function? It would return e^1 or just e, wouldn't it?
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0


<< Perhaps I'm not understanding something but the exp() function supposedly returns e^x where x is the value passed to the function. Couldn't you simply pass 1 to the function? It would return e^1 or just e, wouldn't it? >>



why make it even that complicated, the constant is defined in math.h just include it and use it.
 
Jun 18, 2000
11,218
781
126


<< why make it even that complicated, the constant is defined in math.h just include it and use it. >>


Pardon my ignorance. I've never needed to use e before. Is the constant just 'E'?
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136


<< look in math.h it should be defined as a constant in there, im pretty sure pi is ther also. >>



 

Rahminator

Senior member
Oct 11, 2001
726
0
0
#include <cmath>

This imports various things, among which is a symbolic constant M_E set to 2.71828182845904523536.
 

Bluga

Banned
Nov 28, 2000
4,315
0
0

I also have some easy C question, please help me out.


#1: Will the following print to file or stdout?

fprintf(stdout, "vertices=%d", graph(graph));

#2: Are these two the same?

int main (int argc, char **argv)

int main (int argc, char argv[])

#3: The following is a pointer to void, but what does it mean?

void *data