Randy Brukardt wrote: | | I needed that for a 'choosing' algorithm, say drawing balls one by one | out of a bowl. If you have 8 balls originally, you're choosing 1 out of | 7, then 1 out of 6, etc. If you try to use 1 out of 8 the whole time and | discarding the useless ones, the second last draw can take a very long | time (only 2 out of 8 choices are meaningful). I'm pretty sure that this | is a valid technique; certainly the underlying float generator is still | random (at least as much as it ever was!), and the use of that result is | unbiased. | For this kind of problems, I use the Ada.Numerics.Float_Random generator, along with the function: function Rand (N : Positive) return Positive is -- gives a random integer in the range 1 .. N begin return Integer(Float(N) * Random(Gen) + 0.5); end Rand; It can be used for ranges other than 1 .. N: function Rand (Min, Max : Integer) return Integer is -- gives a random integer in the range Min .. Max begin return Rand(Max - Min + 1) + Min - 1; end Rand; It works as well for enum types: type Enum is (...); function Random_Enum return Enum is -- gives a random Enum value begin return Enum'Val(Rand(Enum'Pos(Enum'Last) + 1) - 1); end Random_Enum; I've never had a problem with this. _______________________________________________________________________________ Jean-Etienne Doucet / LAAS-CNRS / Toulouse, France E-mail: doucet@laas.fr "S'il n'y a pas de solution, c'est qu'il n'y a pas de probl�me." (Les Shadoks)