>>>I do not see any "modulus" operation available in the SORT manual, so it apparently isn't possible to post-process the IEBDG numbers with SORT to convert each of the random numbers modulo the limit value. I suppose division and truncation and subtraction may work, though I haven't figured out how yet.
Peter, DFSORT supports the MOD function along with other arithmetic functions. (ADD,SUB,DIV,MUL) The intermediate or final result of a MOD operation is an integer remainder with the same sign as the dividend. If an intermediate or final result of an arithmetic expression overflows 31 digits, the overflowing intermediate or final result will be truncated to 31 digits, intentionally or unintentionally. If an intermediate or final result of an arithmetic expression requires division or modulus by 0, the intermediate or final result will be set to 0, intentionally or unintentionally. Thanks, Kolusu From: "Farley, Peter x23353" <[email protected]> To: [email protected] Date: 12/11/2017 03:09 PM Subject: Random number generation in a fixed range via utility program(s) only? Sent by: IBM Mainframe Discussion List <[email protected]> Is it possible to do the following using only utility programs and control statements? (z/OS Unix solutions also welcome) Task: Generate 8-digit zoned-decimal numbers from 1 to some limit (e.g., 1 to 8000) in pseudo-random order with exactly one occurrence of each number in the range in the final output, with no gaps (no numbers not present at all) and no repeats (no duplicate numbers). I know that IEBDG can generate random binary integers 4 bytes long, which certainly SORT can then post-process to convert the random binary values to zoned-decimal values, but it does not seem to be possible to confine the generated random numbers to a specific range. I do not see any "modulus" operation available in the SORT manual, so it apparently isn't possible to post-process the IEBDG numbers with SORT to convert each of the random numbers modulo the limit value. I suppose division and truncation and subtraction may work, though I haven't figured out how yet. The other hard problem is to guarantee that there is exactly one occurrence of each number and that no numbers in the range are left out. This task is trivially possible with a fairly simple Rexx program of course, or with any other HLL programming or scripting language that you may choose to use that has a RANDOM function of some kind, but it does not seem to be possible using only "utility" programs and control statements as far as I can tell. Does anyone else have better ideas? Are there z/OS Unix utility programs that can do the job of which I am not aware? If I already have a file of sequentially-numbered records, is there a way to "unsort" them into pseudo-random order? Peter -- This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
