Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  public class example
  {
      public static void main(String[] JAVA_LOL) throws Throwable
      {
          // prints "6"
          System.out.println((int)6.99999);
      }
  }


You (and everyone else) are of course right. I remembered the wrong thing, what I said doesn't apply to that method in Java. What does apply is that there are lots of subtleties in generating random numbers, and there's rarely a reason to re-invent the wheel. There's a good example of how subtle pseudorandomness is in the Java documentation, so I will link that instead of embarrassing myself further: http://download.oracle.com/javase/1.4.2/docs/api/java/util/R...




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

Search: