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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.156.80 with SMTP id f77mr1955996ioe.94.1474141210715; Sat, 17 Sep 2016 12:40:10 -0700 (PDT) X-Received: by 10.157.17.198 with SMTP id y6mr1425822oty.1.1474141210683; Sat, 17 Sep 2016 12:40:10 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!x192no1559199itb.0!news-out.google.com!b4ni3888iti.0!nntp.google.com!u18no1425424ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 17 Sep 2016 12:40:10 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.250.26.106; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 50.250.26.106 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5db08ea5-c088-4d16-9d88-d058e4bc48df@googlegroups.com> Subject: Ada.Numerics.Float_Random.Generator question From: Andrew Shvets Injection-Date: Sat, 17 Sep 2016 19:40:10 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31800 Date: 2016-09-17T12:40:10-07:00 List-Id: Hello, If I want a random float number to be generated, the way that I did this in= the past was something along these lines: function Create_Random_Float( From : in Float; To : in Float) return Float is Seed : Ada.Numerics.Float_Random.Generator; begin Ada.Numerics.Float_Random.Reset(Seed); return From + (Ada.Numerics.Float_Random.Random(Seed) * To); end Create_Random_Float; This works. However, as I'm now looking into the Ada.Numerics.Discrete_Ran= dom package, I've noticed that it can generate a random value based on the = type that is passed in. This appeals to me and I'd like to do the same for= a custom float type (say I want the delta to be 0.01.) As Ada.Numerics.Float_Random.Generator is not a generic package, I can't us= e the same approach. The best way that I can think of is to create the sam= e result using From and To and then cast the result to the custom float typ= e. I hope that there is a better solution to this. Is there?