Hacker News new | past | comments | ask | show | jobs | submit login

> so long as you multiply the random() result by a good-sized constant before you cast to int, it actually does what it's "supposed" to do.

Yeah but since cast binds tighter than multiplication, any code following the pattern `(int) Math.random() * a` is broken and generates 0 every single time.

For the code to work, you need `(int) (Math.random() * a)`: http://www.google.com/codesearch?q=\(int\)\s*\(\s*Math\.rand...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: