CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   help C++ (https://www.cfd-online.com/Forums/main/6553-help-c.html)

flow September 11, 2003 12:16

help C++
 
Hi,

I am new about C++. I want to calculate some functions in my programme, such as sin, cos, power, log, etc. Where can I find their expression in C++? Thanks!


cfd dude September 11, 2003 12:39

Re: help C++
 
You can find intrinsic functions (sin, min, exp, etc.) in the various include files available with the compiler you're using. Such as:

#include <math.h>

cfd dude September 11, 2003 12:41

once more
 
oops - The symbols I typed didn't show up last time. More explicitly, the syntax is:

#include (less than sign)math.h(greater than sign)


flow September 11, 2003 12:46

Re: once more
 
Thank you very much.

I have good fortran knowledge. In #include <math.h>, how to express squared or power calculation?

Maciej Matyka September 11, 2003 14:17

Re: once more
 
Hi, an example #include <cmath> #include <iostream> int main(void) { double a=10; // take e^a std::cout << exp(a) << std::endl; // take a^10 std::cout << pow(a,10) << std::endl; // take sinus(a) std::cout << sin(a) << std::endl; } M. http://panoramix.ift.uni.wroc.pl/~maq


flow September 11, 2003 14:47

Re: once more
 
Thank you very much.

I just try it. It is clear.



All times are GMT -4. The time now is 12:12.