git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8675 8c9fc860-2736-0410-a75d-ab315db34111
@@ -12,6 +12,8 @@ CONST
allbits = 7FFFFFFFH;
halfrange = 20000000H;
step = 7;
+
+ allbitsInv = 1 / REAL(allbits);
TYPE
(** A pseudo-random number generator. This object is not reentrant. *)
@@ -86,7 +88,7 @@ TYPE
PROCEDURE Uniform*(): REAL;
BEGIN
- RETURN Integer() / allbits;
+ RETURN Integer() * allbitsInv;
END Uniform;
(** Return a pseudo-random real number, exponentially distributed. *)