3 ms·
Reminds me of one of my favorite joke programs. #include <stdio.h> #define SIX 1+5 #define NINE 8+1 int main() { printf("%d\n", SIX * NINE);
by Xirdus 5mo ago
Reminds me of one of my favorite joke programs.
#include <stdio.h>
#define SIX 1+5
#define NINE 8+1
int main() {
printf("%d\n", SIX * NINE);
}
- srean 5mo agoDidn't Linus #define THREE as something else in Linux source code. Was that the 2-3-4 tree? Can't seem to find it now.
- Xirdus 5mo agoIt was from some filesystem code. https://news.ycombinator.com/item?id=7296497 https://news.ycombinator.com/item?id=7296497 unsigned three = 1; unsigned five = 5; unsigned seven = 7; These actually get changed through pointers to consecutive powers of 3, 5 and 7 respectively. `three` is initialized to the 0th power of 3, but because only a single 1 is needed by the algorithm, `five` and `seven` are initialized to the 1st powers instead.
- srean 5mo agoAh right. Thank you so much. At least I wasn't hallucinating.