5
\$\begingroup\$

In the CR question "Terminating a C loop when maximum hardware limit reached" the use of a positive sum wrapping to a negative value is used to terminate the loop. The queston was posted to Code Review even though it could reasonably been asked on Stack Overflow instead. The responses have provoked another question:

When fib is less than the max integer value supported prev is also well less than the max integer supported. So, the sum of the two will never exceed the integer size so as to overflow beyond a negative range. The use of the test fib>0 will work in the special case of the Fibonacci numbers but does not generalize. What code would be a better solution for the more general case?

Which is the better fit for the question, Code Review or Stack Overflow?

\$\endgroup\$
7
\$\begingroup\$

Hmm. The rule of thumb I use for Code Review is:

  1. It is working, functional code with no (obvious to the author, anyway) errors

  2. You want aesthetic and subjective peer feedback on this working, functional code

Seems to me this question could go either way?

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .