From: blchrist@terpalum.umd.edu (Brien)
Subject: Random Number Generator Problem
Date: 25 Jul 2003 07:34:23 -0700
Date: 2003-07-25T14:34:24+00:00 [thread overview]
Message-ID: <30c81431.0307250634.77148b62@posting.google.com> (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!
next reply other threads:[~2003-07-25 14:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-25 14:34 Brien [this message]
2003-07-25 15:34 ` Random Number Generator Problem Robert I. Eachus
2003-07-28 13:14 ` Brien
2003-07-25 17:06 ` Anisimkov
2003-07-25 18:05 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox