Re: SDL-News: how to generate a random number in SDL?


Subject: Re: SDL-News: how to generate a random number in SDL?
From: Rick Reed TSE (rickreed#tseng.co.uk)
Date: Mon Feb 17 2003 - 21:41:31 GMT


Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews -----

Scott Shen at Scott.Shen#holleycomm.com wrote on 17/02/2003 18:37:

> Hi:
>
> Random number is used intensively in communication protocols. Is there a
> stadardized way to generate a random number is SDL? Thanks,

Yes - and No.

The ANY expression, for example in

SYNTYPE Byte = INTEGER CONSTANTS (0:256) ENDSYNTYPE Byte;
DCL rb Byte;
rb:=ANY(Byte); /* a Byte value */

returns an unspecified value within the range of values of the specified
sort, constrained to the values of the syntype if a syntype is given. In
other words ANY(Byte) gives an unspecified value in the range 0 to 256.

However, there is no specification of the distribution of the values. Hence,
the following sequences are all consistent with the SDL definition of ANY:

1, 2, 3, 4, 5, 6, ...

10, 10, 10, 10, ...

234, 3, 155, 162, 93, 155 ...

Part of the issue is how to specify the randomness of the numbers.

--
Rick Reed - rickreed#tseng.co.uk
Tel:+44 15394 88462 Mob.:+44 7970 50 96 50

--End text from Rick Reed TSE <rickreed#tseng.co.uk> to sdlnews --- For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>



This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT