Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on 20 bit operations programmers should know.
1.3, 2.2: wrong, shifting by negative number is undefined behavior
2.1: wrong, relies on some specific behavior for signed integer overflow
4, 5, 6, 7, 10, 11, 12, 17.1, 18: wrong, shifting negative numbers is implementation-defined behavior
Some examples will also suffer from integer overflow if the type 'int' is changed to something bigger (because then 1<<n could overflow, you'd need .e.g (uint64_t)1<<n).
There are no comments on this comment yet.
1.3, 2.2: wrong, shifting by negative number is undefined behavior
2.1: wrong, relies on some specific behavior for signed integer overflow
4, 5, 6, 7, 10, 11, 12, 17.1, 18: wrong, shifting negative numbers is implementation-defined behavior
Some examples will also suffer from integer overflow if the type 'int' is changed to something bigger (because then 1<<n could overflow, you'd need .e.g (uint64_t)1<<n).