3 ms·
When I look at the code, I'm under the impression that will generate always the same output because the random seed is fixed (besides the timer). Given current
by wiz21c 9y ago
When I look at the code, I'm under the impression that will generate always the same output because the random seed is fixed (besides the timer). Given current tech, could a compiler see that and just reduce the computation to a simple value ?
- MichaelBurge 9y agoSort of. If rand() wasn't built into the standard, it would be impossible because you could override it at link-time with another function that connects to your database or something. And the linker runs after the compiler. But because it's built-in, the compiler might be able to infer more about it, just like it reduces: printf("x"); to putchar('x');