Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
__mark
on April 22, 2011
|
parent
|
context
|
favorite
| on:
A common bug in published code
Oh, so it always rounds down to zero, that's pretty bad. Casting it to a double would help right?
Thasc
on April 22, 2011
|
next
[–]
Instead of
int runs = (int) Math.random() * 1000000;
You'd do
int runs = (int) (Math.random() * 1000000);
Confusion
on April 22, 2011
|
prev
[–]
That would be pointless, because Math.round already returns a double.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: