| | |
Parsing error
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 30
Reputation:
Solved Threads: 0
Hi all,
I used a function called GetRandomVariable to return a double data type and here's its code:
but unfortunately i got the following error:
Error 1 error C2296: '%' : illegal, left operand has type 'double'
I used a function called GetRandomVariable to return a double data type and here's its code:
C++ Syntax (Toggle Plain Text)
double GetRandomNumber(void) { // Zi = (AZi-1 + C)(mod m) // Zi = (5Zi-1 + 3)(mod 16) RandomVariableGenerator::Znode = (double)((5.0*RandomVariableGenerator::Znode + 3) % 16); return RandomVariableGenerator::Znode/16; } static double Znode = 7.0;
Error 1 error C2296: '%' : illegal, left operand has type 'double'
There is hope!
Use fmod to resolve the modulus between two doubles
Use fmod to resolve the modulus between two doubles
c++ Syntax (Toggle Plain Text)
#include <iostream> using std::cin; using std::cout; using std::endl; int main(){ double x = fmod(4.5, 3.22); cout << x << endl; // 1 R 1.28, so 1.28 should print out cin.get(); return 0; }
![]() |
Similar Threads
- XML Parsing Error: junk after document element (XML, XSLT and XPATH)
- Wordpress Blog Help. Getting Error. Need Help Please. (PHP)
- PHP parsing error, unexpected '<' (PHP)
- SMF parsing error (PHP)
- parsing error (XML file-java-schema) (Java)
Other Threads in the C++ Forum
- Previous Thread: converting bool[8] to char
- Next Thread: automating login to a server using c++
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






