Problem with C++ math

Started by
3 comments, last by monkey_32606 19 years, 6 months ago
I have been programming with Java for a while and never ran into any problems using its math functions, but when I switched over to C++ I cant get any of them to work. Can anyone tell me what to include and how to use cosine , tangent , sine , atan ,etc.
My Current Project Angels 22 (4E5)
Advertisement
First of all, you need to #include <cmath>

The functions are pretty straight forward. I googled this. It seems like a pretty good reference.
Thanks for the fast reply that helped alot.
My Current Project Angels 22 (4E5)
#include <cmath>
using namespace std;

sin( radian )
cos( radian )
Bah real men write their own. (which i still havn't fixed)
#include <iostream>#include <math.h>#define PIENOTCAKE 3.1415926535897932384626433832795unsigned int factorial(unsigned int number){	unsigned int holder = number;	unsigned int i = number;	while (i>0)	{		if (i == 1)		{			break;		}		i--;		holder *=i;	}	return holder;}long double getsigma(long double n, long double x){	//long double retvalue;	//retvalue = ((pow(-1, n))/factorial(2*n + 1))*pow(x,2*n + 1);	return ((pow(-1, n))/factorial(2*n + 1))*pow(x,2*n + 1);}int main(int argc, char *argv[]){	int i = 1;	long double totaler;		totaler = getsigma(0,PIENOTCAKE/3);		while (i<15)	{		totaler += getsigma(i,PIENOTCAKE/3);		i++;	}	std::cout << "Sine of PI/3: "<<totaler<<std::endl;	system("pause");	return 0;}



The Serious Answer:
Cmath
Quote:Michael TanczosCut that shit out. You shouldn't be spying on other people.. especially your parents. If your dad wanted to look at horses having sex with transexual eskimo midgets, that's his business and not yours.

This topic is closed to new replies.

Advertisement