comp.lang.ada
 help / color / mirror / Atom feed
* Random Number Generator Problem
@ 2003-07-25 14:34 Brien
  2003-07-25 15:34 ` Robert I. Eachus
  2003-07-25 17:06 ` Anisimkov
  0 siblings, 2 replies; 5+ messages in thread
From: Brien @ 2003-07-25 14:34 UTC (permalink / raw)


Preface: I'm using GNAT on a windows box.

I'm generating a series of unsigned 64 bit integers and I get the same
value for about half of the results.  The ada built-in random number
generator seems to be giving me 2**63 much more often than any other
number.  I can't figure out why this would be.  Here is some sample
code to demonstrate my problem.

with Interfaces;
with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;
use Ada.Text_Io;
procedure Generate_Random_Test is 
   type Unsigned_Dbl_Integer is new Interfaces.Unsigned_64; 
   package Rand is new
Ada.Numerics.Discrete_Random(Unsigned_Dbl_Integer);
   Rand_Gen : Rand.Generator;  
begin
   for I in 1..1000 loop
      Put_Line(Unsigned_Dbl_Integer'Image(Rand.Random(Rand_Gen)));
   end loop;

end Generate_Random_Test;


When I run this code, i get 9,233,........,808 (which is 2**63) as
about half of my results.

Thanks for the help!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-07-28 13:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-25 14:34 Random Number Generator Problem Brien
2003-07-25 15:34 ` Robert I. Eachus
2003-07-28 13:14   ` Brien
2003-07-25 17:06 ` Anisimkov
2003-07-25 18:05   ` Robert I. Eachus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox