News for hackers. Stuff that matters.
Re:On Binary Search by MauranKilom on Wednesday October 30, 2019 @07:21PM (#21404097)
Java. There are no unsigned integers in Java. Many would consider that a benefit (although opinions vary on signed vs unsigned bytes). FWIW, the creators of C++ have stated that they'd go with signed integers for e.g. indexes in the library interfaces nowadays (but it's way too late to change that).

Popular problem with using unsigned : Write a reverse for loop from n (exclusive) to 0 (inclusive). See if you can do it without discarding your two most intuitive (but wrong) approaches.

Re:On Binary Search by smellia on Thursday October 31, 2019 @02:19AM (#21406156)
Its the opposite. Its easy to write such a loop with unsigned ints: for(x=top;x<=top;x--). However you can't reliably write a loop spanning the whole space with signed ints without breaking the no-overflow rules. With unsigned you can do x=0;do{stuff(x);}while(++x); Good luck doing this with signed ints.
Re:On Binary Search by mypalmike on Thursday October 31, 2019 @10:07AM (#21408915)
This is why integer sign should be part of the operation rather than the type. Every language but assembly gets this wrong.