Question question on three small maths functions

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 14
Reputation: yazooney is an unknown quantity at this point 
Solved Threads: 0
yazooney yazooney is offline Offline
Newbie Poster

Question question on three small maths functions

 
0
  #1
Sep 29th, 2008
Very basic questions but hard to find in google!

  1. return sqrt(eps - 2.*log(eps + rand()/(double) RAND_MAX))*cos(rand()*pi2/RAND_MAX);

The part of the formula where it says "2.*log". I belive the "dot" only represnts that the number 2 is 2.0. However, I am not 100% sure about this as I actually dont see the reason to put "2." instead of just "2" So, does the "dot" indicate 2.0 or does it represent something else?

Second basic question:

  1. aux += ((K-Sp)>0?K-Sp:0)

What does the "?" mean and what does the ":" mean.

Thanks alot
YR
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,484
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Question question on three small maths functions

 
0
  #2
Sep 29th, 2008
1) yes, 2. just means 2.0

2) That is just a shorthand if-else statement. You have to be careful with that because occasionally I've found that it doesn't work correctly.
  1. if( K-Sp) > 0)
  2. aux += K-SP;
  3. else
  4. aux += 0;
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC