Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Random Number Generator

135 views
Skip to first unread message

JDonahue

unread,
Jun 3, 1999, 3:00:00 AM6/3/99
to
Hi There! I'm looking for a compact random number generator that I can
plunk into some RPG code. I realize that the number probably isn't
random, but I'd like to get as close as possible. I've thought about
taking the time in seconds and multiplying that by *LOVAL, but I want
to see if anyone has a slick set of code already written that I can get
by begging real hard. It would be nice if I could tell this routine how
big a number I want and/or a high/low range.

Anyone know where I can find one?

Thanks....

Jim Donahue
James....@ParamountParks.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Njål Fisketjøn (Njal Fisketjon)

unread,
Jun 3, 1999, 3:00:00 AM6/3/99
to

If you're using ILE RPG you can use the API below.

System API Reference
OS/400 Integrated Language Environment (ILE) CEE APIs

Version 4

Document Number SC41-5861-01


5.7.1 Basic Random Number Generation (CEERAN0) API

The Basic Random Number Generation (CEERAN0) API generates a sequence of uniform pseudorandom
numbers between 0 and 1 using the multiplicative
congruential method with a user-specified seed.


Njål Fisketjøn, FIGU DATA AS
n...@figu.no
http://www.robin.no/~nfisketj

Olafur Torfason

unread,
Jun 3, 1999, 3:00:00 AM6/3/99
to
good old TAATOOLs has one.

Gary Guthrie

unread,
Jun 3, 1999, 3:00:00 AM6/3/99
to
I published a procedure from a math service program in The RPG Source
that generates random numbers. Of course, when I went out to the Web
site to double check its location, I noticed an old copy of the service
program.

I just sent it to the webmaster for refresh. You can download the math
service program (Math.zip - might want to wait a little while to make
sure the update gets there!) by clicking the following link

http://www.news400.com/TheRPGSource/Utilities/Math.zip

or by visiting The RPG Source Website at
http://www.news400.com/TheRPGSource and following the link to the
Download Utilities section.

Gary Guthrie
Editor, The RPG Source at http://www.news400.com/TheRPGSource
Technical Editor, NEWS/400 at http://www.news400.com

Craig Rutledge

unread,
Jun 3, 1999, 3:00:00 AM6/3/99
to
If you haven't found one yet, please send an email to me at <
craig.r...@springs.com >. I have got a RPG random number generator that
is a called program.

- - -
JDonahue wrote in message <7j66bu$hoq$1...@nnrp1.deja.com>...

Paul Nicolay

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
Hi Jim,

This should do the trick... (compile with DFTACTGRP(*NO))

DRandomize PR ExtProc('CEERAN0')
D pSeed 9B 0
D pRand 8F
DSeed S 9B 0 Inz
DRand S 8F Inz
C CallP Randomize(Seed:Rand)

Rand will contain a random number between 0 and 1.

Regards,
Paul
-----------


JDonahue wrote in message <7j66bu$hoq$1...@nnrp1.deja.com>...
Hi There! I'm looking for a compact random number generator that I can
plunk into some RPG code. I realize that the number probably isn't
random, but I'd like to get as close as possible. I've thought about
taking the time in seconds and multiplying that by *LOVAL, but I want
to see if anyone has a slick set of code already written that I can get
by begging real hard. It would be nice if I could tell this routine how
big a number I want and/or a high/low range.

Anyone know where I can find one?

Thanks....

Jim Donahue
James....@ParamountParks.com

The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.

Charles R. Pence

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
JDonahue wrote:
>
> Hi There! I'm looking for a compact random number generator that I can
> plunk into some RPG code. I realize that the number probably isn't
> random, <<SNIP>>

http://www.deja.com/[ST_rn=ps]/qs.xp?ST=PS&QRY=ceeran0&defaultOp=AND&DBS=1&OP=dnquery.xp&LNG=ALL&subjects=&groups=comp.sys.ibm.as400.misc&authors=&fromdate=&todate=&showsort=score&maxhits=25

Try info found in DejaNews search for CEERAN0; as above.

Regards, Chuck
All comments provided "as is" with no warranties of any kind whatsoever.

starbu...@my-deja.com

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
In article <7j66bu$hoq$1...@nnrp1.deja.com>,

JDonahue <jgdo...@my-deja.com> wrote:
> Hi There! I'm looking for a compact random number generator that I can
> plunk into some RPG code. I realize that the number probably isn't
> random, but I'd like to get as close as possible. I've thought about

I have one based on an algorithm published in the Communications of the
ACM that is very random. It was originally used to randomly select
employees for drug testing. We needed an algorithm that would hold up
in a court of law as being "mathematically proven."

For less rigourous applications, I'd stick with CEERAN0. It's easy to
work with and less cumbersome to code for.

Buck Calabro
Billing Concepts Albany, NY
mailto:mcal...@commsoft.net

Donna Bryant

unread,
Jun 4, 1999, 3:00:00 AM6/4/99
to
You can call a REXX program. There is a REXX function that returns a
random number.
-donna bryant

JDonahue <jgdo...@my-deja.com> wrote in article
<7j66bu$hoq$1...@nnrp1.deja.com>...


> Hi There! I'm looking for a compact random number generator that I can
> plunk into some RPG code. I realize that the number probably isn't
> random, but I'd like to get as close as possible. I've thought about

> taking the time in seconds and multiplying that by *LOVAL, but I want
> to see if anyone has a slick set of code already written that I can get
> by begging real hard. It would be nice if I could tell this routine how
> big a number I want and/or a high/low range.
>
> Anyone know where I can find one?
>
> Thanks....
>
> Jim Donahue
> James....@ParamountParks.com
>
>

Christian Podesta Carlevaris

unread,
Jun 6, 1999, 3:00:00 AM6/6/99
to Donna Bryant
Usin CL there is a command... can't remember now how it's called but
you can give it a seed and a range.

Saludos

Craig Rutledge

unread,
Jun 7, 1999, 3:00:00 AM6/7/99
to
Email me at work tomorrow. craig.r...@springs.com . I will reply with
the RPG source for a random number generator.


Christian Podesta Carlevaris wrote in message
<375A792B...@mbox.servicenet.com.ar>...

PRM

unread,
Jun 8, 1999, 3:00:00 AM6/8/99
to
here's a sample of some code I wrote last year...

D/COPY QSYSINC/QRPGLESRC,QUSEC
*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D w_time S 6 0
*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D p_seed S 4B 0
D p_RANO S 8F
D api_ERR S LIKE(QUSEC)
********************************************************************
C TIME w_TIME
C Z-ADD w_TIME p_SEED
*
C CALLB 'CEERAN0'
C PARM p_seed
C PARM p_rano
C PARM api_ERR
*
C SETON LR

HTH
Best regards
Pete M. (MJS400 Ltd)

Chris

unread,
Jun 9, 1999, 3:00:00 AM6/9/99
to
Wasn't the CL version in QUSRTOOL?

An alternative is to use ILE RPG for which there is a random number
bindable API. Look in the Math API's manual to find it.

In article <375A792B...@mbox.servicenet.com.ar>, Christian Podesta
Carlevaris <bar...@mbox.servicenet.com.ar> writes


>Usin CL there is a command... can't remember now how it's called but
>you can give it a seed and a range.
>
>Saludos
>
>Donna Bryant wrote:
>>
>> You can call a REXX program. There is a REXX function that returns a
>> random number.
>> -donna bryant
>>

>> JDonahue <jgdo...@my-deja.com> wrote in article
>> <7j66bu$hoq$1...@nnrp1.deja.com>...
>> > Hi There! I'm looking for a compact random number generator that I can
>> > plunk into some RPG code. I realize that the number probably isn't
>> > random, but I'd like to get as close as possible. I've thought about
>> > taking the time in seconds and multiplying that by *LOVAL, but I want
>> > to see if anyone has a slick set of code already written that I can get
>> > by begging real hard. It would be nice if I could tell this routine how
>> > big a number I want and/or a high/low range.
>> >
>> > Anyone know where I can find one?
>> >
>> > Thanks....
>> >
>> > Jim Donahue
>> > James....@ParamountParks.com
>> >
>> >
>> > Sent via Deja.com http://www.deja.com/
>> > Share what you know. Learn what you don't.
>> >

--
Chris

Craig Rutledge

unread,
Jun 10, 1999, 3:00:00 AM6/10/99
to
Send me an email at work tomorrow, < craig.r...@springs.com > I will
reply with the RPG source for a callable random number generator.

Chris wrote in message ...

0 new messages