News for hackers. Stuff that matters.
Re:Fast midpoint between two integers without overflow by munificent on Wednesday December 07, 2022 @02:38PM (#33899125)
> Since the width of the operands are known ahead of time, a wider integer can be unconditionally reserved on the stack for the result of the operation.

What is the width of `i` in:

    foo(int count) {
      int i = 0;
      for (int j = 0; j < count; j++) {
        i = i + i;
      }
    }
Re:Fast midpoint between two integers without overflow by zmgsabst on Wednesday December 07, 2022 @03:14PM (#33899615)
You probably want i=1 since i=0 is an answer you can predict:

i = 0 implies that i = 0 + 0 = 0; so the loop doesn’t evolve, and the whole thing can be optimized to just i = 0.

For i=1, the loop simplifies to 2^count and a count-length type, which is the point I think you wanted.

Re:Fast midpoint between two integers without overflow by munificent on Thursday December 08, 2022 @12:56PM (#33910895)
Heh, oops, yes. :)