From: tonyg on
I want to generate a random integer and a random floating point number
between 10 and 30 . I've been looking at previous posts and finding it
a little confusing with many packages, has anyone an already done
example in ada 2005 they can post up?
From: Jacob Sparre Andersen on
tonyg <tonythegair(a)googlemail.com> writes:

> I want to generate a random integer and a random floating point number
> between 10 and 30 . I've been looking at previous posts and finding it
> a little confusing with many packages, has anyone an already done
> example in ada 2005 they can post up?

There is an example in section A.5.2 in the reference manual.

Jacob
--
There only exist 10 kinds of people: Those who know binary
numbers and those who don't know binary numbers.
From: Dmitry A. Kazakov on
On Tue, 13 Jul 2010 05:45:47 -0700 (PDT), tonyg wrote:

> I want to generate a random integer and a random floating point number
> between 10 and 30 . I've been looking at previous posts and finding it
> a little confusing with many packages, has anyone an already done
> example in ada 2005 they can post up?

An example of Gaussian distribution:

http://rosettacode.org/wiki/Random_numbers#Ada

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Thomas Løcke on
On 2010-07-13 14:45, tonyg wrote:
> I want to generate a random integer and a random floating point number
> between 10 and 30 . I've been looking at previous posts and finding it
> a little confusing with many packages, has anyone an already done
> example in ada 2005 they can post up?


Hey tonyq,

I wrote this little tutorial a while ago:

http://wiki.ada-dk.org/index.php/The_Dice_Roller_Program

As the name suggests, the tutorial centers around a program that rolls
dice, and as such it needs to generate some random numbers. The part the
does the random stuff can be found here:

http://wiki.ada-dk.org/index.php/The_Dice_Roller_Program#dice-random.ads_and_dice-random.adb

It's not a very complicated routine, so you should be able to tweak it
to match your needs. :o)

--
Regards,
Thomas L�cke

Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke
From: Jeffrey R. Carter on
On 07/13/2010 05:45 AM, tonyg wrote:
> I want to generate a random integer and a random floating point number
> between 10 and 30 . I've been looking at previous posts and finding it
> a little confusing with many packages, has anyone an already done
> example in ada 2005 they can post up?

The random integer is pretty easy to do with an appropriate [sub]type and
Ada.Numerics.Discrete_Random. The random floating-point is a bit more difficult,
and there's always the question of whether 30.0 must be a possible value. You
can have a look at Random_Range in PragmARC.Universal_Random:

http://pragmada.x10hosting.com/pragmarc.htm

which excludes the maximum value from the returned values.

--
Jeff Carter
"When Roman engineers built a bridge, they had to stand under it
while the first legion marched across. If programmers today
worked under similar ground rules, they might well find
themselves getting much more interested in Ada!"
Robert Dewar
62