× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks, but I have figured it out.

Apparently a seed of type 5I doesn't quite work ok.  I made it 10I and now
it's really random.

Peter Colpaert
Application Developer
Honda Europe NV
----------
Yoda of Borg are we: Futile is resistance. Assimilate you, we will.
----------




"Robin Coles" <robin@ringbase.com>@midrange.com on 16/01/2002 10:28:35

Please respond to rpg400-l@midrange.com

Sent by:  rpg400-l-admin@midrange.com


To:   <rpg400-l@midrange.com>
cc:

Subject:  RE: Random number generation


I think you need to set COSEED to something vaguely random before you
start.  I combine the day number, job number and time as a start point
but there's probably a better way.

255a d BigNum          s             11  0
255a d SmallerNum      s              9  0

255a C                   If        Not SetSeed
     C                   TIME                    XXTMDT
255a C     XXSS          IFNE      0
255a
255a C     Z1JobN        Mult      XXMMSS        BigNum
255a C     BigNum        Div       XxDay         SmallerNum
255a
255a **  Need to use smallernum to control overflow as the max in
255a **  a 10i field is 2147483647
255a
255a c                   Z-Add     SmallerNum    Seed
255a c                   Else
255a C                   Z-Add     Z1JobN        Seed
255a C                   EndIF
255a C                   Eval      SetSeed = *On
255a C                   EndIf
255a
255a **  CEERAN0 generates a pseudo-random number between 0 and 1.
Factor
255a **  up to a 6 digit number once done.  Leave the seed for the next
call
255a
255a c                   CallB     'CEERAN0'
255a c                   Parm                    Seed
255a c                   Parm                    Number
255a c                   Parm                    Feedback         12

Cheers
Robin

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.






As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.