21.9
java.util.Random
THE PACKAGE JAVA.UTIL
21.9.7
protected int next(int bits)
The general contract of
next
 is that it returns an
int
 value and if the argument
bits is between
1
 and
32
 (inclusive), then that many low order bits of the returned
value will be (approximately) independently chosen bit values, each of which is
(approximately) equally likely to be
0
 or
1
.
The method
next
 is implemented by class
Random
 as follows:
synchronized protected int next(int bits) {
seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48)   1);
return (int)(seed >>> (48   bits));
}
This is a linear congruential pseudorandom number generator, as defined by D. H.
Lehmer and described by Donald E. Knuth in
The Art of Computer Programming
,
Volume 2:
Seminumerical Algorithms
, section 3.2.1.
21.9.8
public int nextInt()
The general contract of
nextInt
 is that one
int
 value is pseudorandomly gener 
ated and returned. All 2
32
possible
int
 values are produced with (approximately)
equal probability.
The method
setSeed
 is implemented by class
Random
 as follows:
public int nextInt() {  return next(32); }
21.9.9
public long nextLong()
The general contract of
nextLong
 is that one
long
 value is pseudorandomly gen 
erated and returned. All 2
64
possible
long
 values are produced with (approxi 
mately) equal probability.
The method
setSeed
 is implemented by class
Random
 as follows:
public long nextLong() {
return ((long)next(32) << 32) + next(32);
}
648






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved