FW: SDL-News: random number generating


Subject: FW: SDL-News: random number generating
michael.andersson#telelogic.com
Date: Thu Aug 28 2003 - 13:41:51 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 michael.andersson#telelogic.com to sdlnews -----

Could perhaps be of interest to the community.

/Michael

----------------------------------------------------------------------------
----------
Telelogic Tau Generation 2 - Development Visualized. Productivity Realized.
Learn more about Telelogic's new software development solution at
http://www.taug2.com

Michael Andersson <mailto:michael.andersson#telelogic.com>
Field Application Engineer Phone: +46 40 17 47 00
Telelogic Direct: +46 40 17 47 65
P.O. Box 4128 Mobile: +46 705 17 47 65
SE 203 12 MALMO Fax: +46 40 17 47 47
Sweden <http://www.telelogic.com>

Telelogic - Automating the development lifecycle
----------------------------------------------------------------------------
----------

-----Original Message-----
From: Michael Andersson
Sent: den 28 augusti 2003 15:41
To: 'Yang LIU'
Subject: RE: SDL-news: random number generating

Dear Yang,

The SDL way of doing this is to define a syntype that matches the wanted
integer range:

  syntype niceWeather = Integer
    constants 20:25
  endsyntype;

  dcl myIntVar Integer;

and then in a task to use any like the following:

  myIntVar := any(niceWeather)

This will work fine if you are happy with a uniform distribution. If you
want other distributions, you can define operators that calculate these from
the uniform distribution given by any().

If you are using Telelogic TAU SDL Suite, then normally you could use a
library of types and operators for random numbers and distributions, the
random ADT. This is located in <sdl suite
installation>\sdt\include\ADT\random.pr
Please consult the documentation for how to use this ADT. However, the C
implementation of this ADT is partly based on floats, so if this is not
supported on your target, that will not work.

An alternative: if you have access to a C library for random (int)
functions, you also might consider importing these C definitions to SDL (as
external SDL definitions). How to import C/C++ is also described in the
documentation.

regards
Michael Andersson

----------------------------------------------------------------------------
----------
Telelogic Tau Generation 2 - Development Visualized. Productivity Realized.
Learn more about Telelogic's new software development solution at
http://www.taug2.com

Michael Andersson <mailto:michael.andersson#telelogic.com>
Field Application Engineer Phone: +46 40 17 47 00
Telelogic Direct: +46 40 17 47 65
P.O. Box 4128 Mobile: +46 705 17 47 65
SE 203 12 MALMO Fax: +46 40 17 47 47
Sweden <http://www.telelogic.com>

Telelogic - Automating the development lifecycle
----------------------------------------------------------------------------
----------

> -----Original Message-----
> From: Yang LIU [mailto:lyly97#mails.tsinghua.edu.cn]
> Sent: den 28 augusti 2003 10:04
> To: sdlnews#sdl-forum.org
> Subject: SDL-news: random number generating
>
>
> 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 "Yang LIU" <lyly97#mails.tsinghua.edu.cn>
> to sdlnews -----
>
> Hi members,
>
> I need a random integer number generated betweem 0 and Var
> in SDL, where Var is the integer variable. I know use the ANY
> can generate a random, but in this method, the range is
> predefined. My range is defined by variable, and I can't
> apply any float operation as the embedded processor doesn't
> support it, Is there a easy way to generate integer random to
> meet my request?
>
> thanks a lot.
>
> Best Regards,
> Yang Liu
>
>
> --End text from "Yang LIU" <lyly97#mails.tsinghua.edu.cn> to
> sdlnews --- For extra SDL Forum Society > benefits join at
> <http://www.sdl-forum.org/Society/members.htm>
> For help, email "majordomo#sdl-forum.org" with the body of
> your email as:
> help
> or (iff this does not answer your question) email:
> owner-sdlnews#sdl-forum.org
>
--End text from michael.andersson#telelogic.com 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:50 GMT