From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,47a3564e17a59a63,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-07 15:39:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: brianc@billybob.demon.co.uk (Brian A Crawford) Newsgroups: comp.lang.ada Subject: Pseudo Random coding problem Date: Tue, 07 Jan 2003 23:47:50 GMT Message-ID: <3e1b633f.3280604@news.demon.co.uk> NNTP-Posting-Host: billybob.demon.co.uk X-Trace: news.demon.co.uk 1041982786 17350 194.222.76.2 (7 Jan 2003 23:39:46 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 7 Jan 2003 23:39:46 +0000 (UTC) X-Newsreader: Forte Free Agent 1.11/32.235 Xref: archiver1.google.com comp.lang.ada:32709 Date: 2003-01-07T23:47:50+00:00 List-Id: I am trying to start a small programming project that will output pseudo-random numbers. The program looks at the numbers produced and if that number equals a predetermined value (20 in the case in the test program below) the program will then catch this fact and perform a number of loops and counts etc. However I've fallen at the first hurdle. I've heavily borrowed code from Ada95 by Feldman/Koffman (thankyou!) and find that the program sometimes sees the value 20 and on other occasions doesn't. It's very tempermental. The code is below. Ive definitely missed something. ________________________________________________ WITH Ada.Text_IO; WITH Ada.Integer_Text_IO; WITH Ada.Float_Text_IO; WITH Ada.Numerics.Discrete_Random; procedure Random_Numbers is SUBTYPE RandomRange IS positive RANGE 1..50; PACKAGE Random_50 IS NEW Ada.Numerics.Discrete_Random (Result_Subtype => RandomRange); G: Random_50.Generator; BEGIN -- Random_Numbers Random_50.Reset (Gen => G); -- starts G from time of day clock for row in 1..15 loop Ada.Integer_Text_IO.Put (Item => Random_50.Random(Gen => G), Width => 8); if Random_50.Random(Gen => G) = 20 then Ada.Text_io.put (Item => "Random Number is equal to Twenty"); Ada.text_io.new_line; end if; Ada.text_io.new_line; end loop; END Random_Numbers; _______________________________________________________