Yes, tilde zero (~0) is a bit-wise "not" of 0, that is, an integer with all bits set. So it gets interpretted as an unsigned value and tells rand() to give back a random pattern of bits (a random number between 0 and (~0)-1, inclusive).
Gee, I guess I should be using rand(1+~0) from now on. Oh well, that would only be a minor improvement. (:
- tye (but my friends call me "Tye")In reply to (tye)Re2: Generating Random Integers
by tye
in thread Generating Random Integers
by --OutpostMir--
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |