Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

WHILE loop freezes

Posted on 2003-03-14
3
Medium Priority
?
219 Views
Last Modified: 2010-05-18
Hi,
my while loop freezes for some reason unknown to me. I have tested the same loop in an excel spreadsheet and in VBA and it works. I am missing something, not sure why. The code (for an excel add-in) is below:

double dy = fabs(RGWci-RGWI-RGWD+RGWX);
     while (dy>RGWepsilon && (RGWHighS-RGWLowS)>RGWepsilon);
     {
          if((RGWci-RGWI-RGWD+RGWX)<0)
          {
               RGWHighS = RGWI;
          }
          else
          {
               RGWLowS = RGWI;
          }
          RGWI = (RGWHighS+RGWLowS)/2;
          RGWci = *ad_GBS("call","stock",RGWI,RGWX,RGWvol,RGWR,0,(RGWT-RGWt),"value");
          dy = fabs(RGWci-RGWI-RGWD+RGWX);
     }
Any help welcome, thanks.
0
Comment
Question by:decornez
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 8135313
>> while (dy>RGWepsilon && (RGWHighS-RGWLowS)>RGWepsilon);

Remove the semi-colon at the end of this line!

Mayank.
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 200 total points
ID: 8135320
In continuity with my last comment - the condition is always remaining true as it is never entering the { .. } block after the while loop but is stopping at the ';' (null statement) and then looping forever as the variables are not being modified at all.

Mayank.
0
 

Author Comment

by:decornez
ID: 8135360
Yes, that was clearly the problem. Thanks a lot, can't believe I missed that ! ahahaha Always good to have another pair of eyes. Well done.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question