Home Forums Gamescan Chat42 About
* Login   * Register * FAQ    * Search
It is currently Thu 11-20-2025 12:53PM

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: c++ math formula
PostPosted: Wed 02-16-2005 11:45PM 
Offline
Lieutenant

Joined: Mon 10-04-2004 5:17PM
Posts: 68

Source: TJ North
how do i write this in c++ language?

pi = 4 [ 1 - 1/3 + 1/5 - 1/7 + 1/9 ... + ((-1)**N)/(2N + 1) ]

i have pi = 4 * ( 1 - ((pow(-1, n))/((2 * n) + 1));
and its not working.

thanks

_________________
Obsession is a word the lazy use to describe the dedicated.


Top
 Profile  
    
 Post subject:
PostPosted: Wed 02-16-2005 11:53PM 
Offline
Major

Joined: Mon 04-14-2003 2:22PM
Posts: 334

Source: Somewhere On Campus
This might get a better response in the Academics thread... other than that, I wish I could help... I'm taking java and we're just getting into the math stuff... sorry man.

Carl

[mod edit: Yes, it would. Next time, Monster, just wait for one of us to take care of it; don't double-post.]


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 12:28AM 
Offline
Colonel
User avatar

Joined: Sun 03-31-2002 10:08PM
Posts: 707
Location: Over your shoulder

Source: Off Campus
check your parenthases...you are missing a ) somewhere. You have 6 ('s and 5 )'s

_________________
Phil the Lame goat is a stupid fucking 'tard

c : enter : push push push

If the women don't find you handsome, they should at least find you handy.

I wouldn't be caught dead with a necropheliac... -- Ebay auction


Top
 Profile E-mail  
    
 Post subject:
PostPosted: Thu 02-17-2005 1:06AM 
Offline
Penis Hater
User avatar

Joined: Mon 02-16-2004 1:47PM
Posts: 2106

Source: Fidelity
Well, because that's not the same formula...

If I go and assume that it's a loop and you go through and add a term to it every time, then you'd have to make it pi +=, so that it will add the term every time instead of reassigning pi a different number not based on the last ones.

_________________
My girlfriend went to London and all I got was this lousy sig.

My new title was my idea...


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 7:01AM 
Offline
Major

Joined: Wed 03-19-2003 12:40AM
Posts: 343

Source: Delta Tau Delta
#define pi 3


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 10:18AM 
Offline
Sergeant

Joined: Mon 10-11-2004 7:13PM
Posts: 46

Source: TJ South
I thought i remembered the pow funtion only using floats too. try putting ".0" after your numbers.


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 11:28AM 
Offline
Lieutenant

Joined: Mon 10-04-2004 5:17PM
Posts: 68

Source: TJ North
problem is fixed...thanks

this is what i had to do.

If I go and assume that it's a loop and you go through and add a term to it every time, then you'd have to make it pi +=, so that it will add the term every time instead of reassigning pi a different number not based on the last ones.

_________________
Obsession is a word the lazy use to describe the dedicated.


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 12:44PM 
Offline
Penis Hater
User avatar

Joined: Mon 02-16-2004 1:47PM
Posts: 2106

Source: Off Campus
BAM!

_________________
My girlfriend went to London and all I got was this lousy sig.

My new title was my idea...


Top
 Profile  
    
 Post subject:
PostPosted: Thu 02-17-2005 7:02PM 
Offline
Gun Hater
User avatar

Joined: Fri 09-03-2004 1:27PM
Posts: 2748
Location: 752 TJ

Source: TJ South
or you could write you own programs instead of asking people how to write it... but maybe thats just me.

_________________
And the tongue is a flame of fire. It is full of wickedness that can ruin your whole life. It can turn the entire course of your life into a blazing flame of destruction, for it is set on fire by hell itself.


Top
 Profile E-mail  
    
 Post subject:
PostPosted: Thu 02-17-2005 7:29PM 
Offline
Penis Hater
User avatar

Joined: Mon 02-16-2004 1:47PM
Posts: 2106

Source: Fidelity
He didn't ask anyone to write it for him, he was stumped on why one part wasn't working, so he asked for help. Way to be a troll.

_________________
My girlfriend went to London and all I got was this lousy sig.

My new title was my idea...


Top
 Profile  
    
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group