V
Vector
Is any infinite loop better than other? Is there any difference between
there efficiency?
there efficiency?
Vector said:Is any infinite loop better than other? Is there any difference between
there efficiency?
Define better.Vector said:Is any infinite loop better than other? Is there any difference between
there efficiency?
Vector said:Is any infinite loop better than other? Is there any difference between
there efficiency?
Is any infinite loop better than other? Is there any difference between
there efficiency?
well answer is very obviousGaijinco said:This is slightly off-topic but I found it intresting: What does this
code prints?
#include <iostream>
int main()
{
int i=1;
while(i>0)
++i;
std::cout << i;
return 0;
}
This is slightly off-topic but I found it intresting: What does this
code prints?
#include <iostream>
int main()
{
int i=1;
while(i>0)
++i;
std::cout << i;
return 0;
}
well answer is very obvious
it will print negative number that is shortest one.
reason : consider the same code with little modification for ur
understanding
int main()
{
char i=1;
while(i>0)
++i;
std::cout << int(i);
std::cin.get();
return 0;
}
print -128
i increments from 1 to 127 than incrementing further will make it 127
to -128
Is any infinite loop better than other? Is there any difference between
there efficiency?
Jack said:How could one infinite loop be better than another? Could one be
infinitely more infinite than the other? If one ends before the other
does, the comparison was invalid because the one that ends was not an
infinite loop to begin with.
Rolf said:It might do this, or it might do anything else. The overflow behavior of
signed integers is undefined.
Old said:This is actually a case of out-of-range assignment:
i is promoted to int for the expression ++i, and the result is then
reassigned to i.
Rolf said:<nitpick>unless char is signed and sizeof(int)==sizeof(char)</nitpick>.
The other example that used int for i was doing what I wrote. Anyway, what
would be the behavior here? Is the value just truncated (modulo) or is it
UB too?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.