- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Generating a random number in DCL
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 10:56 PM
06-16-2005 10:56 PM
Generating a random number in DCL
Can anybody help ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:21 PM
06-16-2005 11:21 PM
Re: Generating a random number in DCL
how random do you need it?
In cases like this I usually let the system clock work for me.
Mind: use SEPARATE F$CVT calls!
Note: spacing around single & double quotes for readability only. Remove in code.
$ one = f$cvtime( "" ,, " hundredth " )
$ two = f$cvtime( "" ,, " second " )
$! need odd number of digits:
$ two = f$extract(1,1, " ' ' two ' " )
$ three = f$cvtime( "" ,, " hundredth " )
$ wait 0:0:0. ' two '
$ four = f$cvtime( "" ,, " hundredth " )
$
$ rand = " ' ' one' ' ' two ' ' ' three ' ' ' four ' "
Make this a subroutine, and re-activate at each need of rand
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:39 PM
06-16-2005 11:39 PM
Re: Generating a random number in DCL
Watch out (sic) using just the clock, of system page faults, or such as a seed, as it may readily result in steady progression in the low order digits.
------ from an old note by 'mulp' ----------
The following seems to be the best compromise between performance and the
generally accepted recommendations. While the top two bits are discarded,
the next 5-10 bits are used for calculating a number from 0 to range-1.
$ seed = seed*69069 + 1 ! alternate $ seed = seed*987654317 + 1
$ value = (seed.and.%x3FFFFFFF)/(%x40000000/range)
---------------------------------------
If you want repeatable random, then pick the same seed every time. If not, seed with time or pagefaults, or whatever.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2005 11:51 PM
06-16-2005 11:51 PM
Re: Generating a random number in DCL
the comments at the beginning.
regards Kalle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 12:00 AM
06-17-2005 12:00 AM
Re: Generating a random number in DCL
Niall.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2005 12:06 AM
06-17-2005 12:06 AM