|
Yes I am using an 8f. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Wilt, Charles Sent: Friday, March 16, 2007 10:02 AM To: RPG programming on the AS400 / iSeries Subject: RE: Random Numbers You sure about that? Are you calling it correctly? Are you using an 8 byte floating point variable to hold the returned value? If yes to all the above, call IBM as the docs say: "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." Charles -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Doug Palme Sent: Friday, March 16, 2007 10:53 AM To: 'RPG programming on the AS400 / iSeries' Subject: RE: Random Numbers Actually it is returning a value between 1 and < 10 -----Original Message----- From: rpg400-l-bounces+dpalme=hdsmith.com@xxxxxxxxxxxx [mailto:rpg400-l-bounces+dpalme=hdsmith.com@xxxxxxxxxxxx] On Behalf Of Wilt, Charles Sent: Friday, March 16, 2007 9:52 AM To: RPG programming on the AS400 / iSeries Subject: RE: Random Numbers Doug, CEERAN0 returns a floating point value between 0 and 1. So to get a number between 1 and 1000, simply multiple the value returned by CEERAN0 by 1000 HTH, Charles -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Douglas Palme Sent: Friday, March 16, 2007 10:41 AM To: 'RPG programming on the AS400 / iSeries' Subject: Random Numbers I have been looking for a random number generator for RPG and found an example on IBM's website. I know that with other languages I can specify that I want the random numbers that are generated to fall within a specified range, IE: between 1 and 1000. Here is the code that IBM suggested: Fseedpf uf e disk usropn F Frandpf o e disk usropn F DTimes c const(1000) Dfactor c const(10000000000) D Dstdpacked s 15p 5 Dstdint s 10i 0 Dstddouble s 8f Dstdfc s 12a D Drandnum_gen pr extproc('CEERAN0') Dpr_seed LIKE(stdint) Dpr_randum like(stddouble) Dpr_fc like(stdfc) D Dcounter s like(stdint) D Dseednum s like(stdint) D Drandnum s like(stddouble) Dfeedbackcode s like(stdfc) D C open seedpf C open randpf C C read seedrec C eval seednum = %rem(seedfld:factor) C for counter = 1 by 1 to times C callp randnum_gen(seednum:randnum:feedbackcode) C eval randfld = randnum C write randrec C endfor C eval seedfld = seednum C update seedrec C close randpf C close seedpf C eval *inlr = *on Maybe I am blinding myself here, but with using the C API, I do not see any way of setting a range. Has anyone else performed such an operation before? If so, how did you specify the lower and upper range? **************************************************************************** This transmission may contain information that is privileged, Confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. **************************************************************************** -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. This e-mail transmission contains information that is intended to be confidential and privileged. If you receive this e-mail and you are not a named addressee you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this communication without the consent of the sender and that doing so is prohibited and may be unlawful. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please delete and otherwise erase it and any attachments from your computer system. Your assistance in correcting this error is appreciated. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. **************************************************************************** This transmission may contain information that is privileged, Confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. ****************************************************************************
As an Amazon Associate we earn from qualifying purchases.
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.