visual c++ - Comparing double error C++ -


Recently, while comparing a double in a statement, I could collide in a problem. I was trying to compete in the number of whole numbers in the double, being initial, I'm not sure what went wrong in my code.

This is my code:

  #include & lt; Iostream & gt; using namespace std; Int main () {int x = 0; Double double double int to double; // long double = 10; // Input Double // Loop while initializing (in & gt; 0) {x = in; // Convert from Double to Integer Out = (X / In); // Out (test if the whole number, return 1) test for // 1 //////////////// (out = = 1) {cout & lt; & Lt; "[Whole number]"; } //////////////// Test & COAT & lt; & Lt; "In:" & lt; & Lt; In & lt; & Lt; "," ;; Cout & lt; & Lt; "X:" & lt; & Lt; X & lt; & Lt; "," ;; Cout & lt; & Lt; "Out:" & lt; & Lt; Out & lt; & Lt; Endl; In-> 0.1 =; // Loop to eliminate (finally)} / / loop termination cin.get (); Return 0; }  

This program will test the whole number in double number and input it. I realized that the accuracy of the double was affecting the statement so I could not get the "[whole number]" result though I found out that if I ("Out> = 0.9 99)" (will work in comparison) I have used (0.9999) but I have no solution, please help! greatly appreciate!

While your loop does not close, it is an infinite loop, you have the value of "in" in the loop So it will always be bigger than 0, so an infinite loop is there.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -