mikemccand commented on issue #12771: URL: https://github.com/apache/lucene/issues/12771#issuecomment-1798212632
Indeed, the javadocs have the same terrifying explanation -- thanks @dungba88!: `If bound is a power of two then limiting is a simple masking operation. Otherwise, the result is re-calculated by invoking nextInt() until the result is greater than or equal zero and less than bound.` Fortunately, thanks to @rmuir digging into OpenJDK sources, it looks like this is a false alarm: these methods first pre-mask to the "next largest power of 2" fully containing the requested range, and iteratively pull random numbers in that range, until finding one within the requested (not necessarily power of 2) range. So the number of iterations of that loop is "typically" very low (1 or 2). I cancelled the PR (#12772) and forgot to close this issue -- closing now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org