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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5291fa0ea59b8b29 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Random Number Generation Date: 1996/10/02 Message-ID: #1/1 X-Deja-AN: 186762009 references: <5266q1$a0t@netty.york.ac.uk> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-10-02T00:00:00+00:00 List-Id: In article <52ten0$ish@netty.york.ac.uk> njt@minster.york.ac.uk (Nigel J. Tracey) writes: > Thanks for all the replies on this issue. I now have the problem > sorted for discrete random values. However nobody has suggested > a solution for generating large random reals. I really need > to be able to generate random values in the range of > Float'Safe_First..Float'Safe_Last. Or perhaps a variable > sub-range of these. Any idea... With what distribution? If you are using this for testing arithmetic units, I suggest unchecked converting a string of random bits of the right length. This will be a distribution which covers all representable numbers equally. (To save Robert Dewar the trouble...Certain bit patterns do not correspond to legal floating point values. This a legitimate use for 'VALID). However if you want a numerically uniform distribution: 2.0 * Float'Safe_Last * (Ada.Numerics.Float_Random.Random(Gen) - 0.5); Actually you may want to add more bits to the typical floating point generator value. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...