| | |
Question question on three small maths functions
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 14
Reputation:
Solved Threads: 0
Very basic questions but hard to find in google!
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:
What does the "?" mean and what does the ":" mean.
Thanks alot
YR
C++ Syntax (Toggle Plain Text)
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:
C++ Syntax (Toggle Plain Text)
aux += ((K-Sp)>0?K-Sp:0)
What does the "?" mean and what does the ":" mean.
Thanks alot
YR
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.
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.
C++ Syntax (Toggle Plain Text)
if( K-Sp) > 0) aux += K-SP; else 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.
![]() |
Other Threads in the C++ Forum
- Previous Thread: How to convert MPEG-2 video file to wmv vdieo file in C++.NET
- Next Thread: asterisks square
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






