What should I write within a while loop that allows me to keep on divding a number by 2 until it meets certain conditions. for example

while(condition)
{
//what should i write here to have a double that divides by 2 until it meets the condition.
}

Recommended Answers

All 2 Replies

While(true){
   Number/2;
   If(condition)
         break;
}

.. or simply

double d = ....
while (condition) {
   d = d/2;
}

ps. Watch out for capitalisation. It's while, not While, and we always give variables names that begin with a lower case letter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.