Random
Previous Topic  Next Topic 

Product

Random

Manufacturer

Standard Satellite Forms component

Website

http://www.satelliteforms.net/

Source code provided

Yes

Platform

PalmOS, PocketPC

Sample project(s)

Random

Keywords

random, drand48


After planting the initial seed this extension will provide the user with some somewhat uniform, psuedo-random numbers.  This extension is based on the drand48 standard.  This standard generates numbers through 48-bit arithmetic provided by the following  equation: 

X[I + 1] = (a*X[I] + c) mod (2^48), where a equals the hex value 5DEECE66D and c equals the hex value B.



Scripts API


All methods in this extension are global unless mentioned otherwise.


Usage:  Global Method:  [Name of method]

             Private Method:  [Name of extension].[Name of method]

Example of usage:

  Global Method:  SRand48(3532)

  Private Method:  Extensions(“Random Number Generator”).About()



About()

Private method that shows the extension's about box.


DRand48()

This function returns a psuedo-random number greater than 0 and up to and including 1.


Seed_Val()

Returns the seed value entered after having used SRand48().


Seed_Val16V(integer)

Returns 16 bits of the three orders of the 48 bit seed value used with Seed48(). 

Example of usage:  'value = Seed_Val16V(3)' returns the highest 16 bits of the seed value entered by Seed48().


Seed48(integer, integer, integer)

The three integer values that are passed to this method are assigned to X[0].  The first parameter passed is the lowest 16 bits.  The second parameter becomes the next 16 bits.  And, the last value becomes the highest order 16 bits of the 48 bit initial X, X[0]. 

Example of usage:  Seed48(X1, X2, X3) where X1 is the first 16 bits, X2 the second, and X3 is the last 16 bits of the 48 bits value seeded into X[0].


SRand48(integer)

SRand48 takes the integer value you pass it as the seed value and assigns the highest 32 bits of X[0] to that value.  The remaining 16 bits are given the hex value of 330E. 

Example of usage:  'SRand48(3532)'.


X_Buffer(integer)

Returns the current X[i] value from X[i] = (a*X[i-1] + c)mod 2^48.  Enter a number from 1 to 3 and this will return the lowest to highest 16 bits of X[i] respectively. 

Example of usage:  'value = X_buffer(1)' returns the first 16 bits of X[i].


X_Initial(integer)

Returns 16 bits of the initial 48 bit X[i] value. 

Example of usage:  'value = X_Initial(3)' returns the highest-order 16 bits of X[0].


X_Last(integer)

Returns the last, X[i-1], value from X[i] = (a*X[i-1] + c)mod(2^48).  Enter a number from 1 to 3 and this will return the lowest to highest 16 bits of X[i] respectively. 

Example of usage:  'value = X_Last(1)' returns the first 16 bits of X[i-1].



DocID: 10147  DocDate: 2005-07-18