News for hackers. Stuff that matters.
Re:A common bug in published code by Adrock on Thursday April 21, 2011 @05:53PM (#2472547)
See the previous HN discussion: http://news.ycombinator.com/item?id=960886
Re:A common bug in published code by __mark on Friday April 22, 2011 @06:35AM (#2473697)
Oh, so it always rounds down to zero, that's pretty bad. Casting it to a double would help right?
Re:A common bug in published code by Thasc on Friday April 22, 2011 @07:14AM (#2473745)
Instead of

int runs = (int) Math.random() * 1000000;

You'd do

int runs = (int) (Math.random() * 1000000);

Re:A common bug in published code by Confusion on Friday April 22, 2011 @02:06PM (#2474864)
That would be pointless, because Math.round already returns a double.