Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others?
Thanks.
Can anybody tell me what actually is a "Sentinel Loop"? How is it different from others?
Thanks.
A loop that stops when a predetermined "sentinal" value is reached. For character arrays, this is the value zero, and infact all of the string.h functions rely on this fact to function properly.
while( array[i] != sentinal ){
//...process data...
}
This is opposed to the approach of looping till a certain limit is reached:
while( i < max ){
array[i++] = //...
}
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }