Mail Archives: djgpp-workers/1998/11/23/12:12:20
DJ said:
> If you mean cut-and-paste into stdlib.h, then it needs to follow the
> style of stdlib.h,
Ok. No extern and less white space. Something else?
Could someone write the documentation? I don't think I'm too suited for that
due to my very thorough reading of the Linux man page.
I found that {l,n}rand48 return to big values. If you're going to try those
functions I suggest you use the following implementation instead.
Right,
MartinS
----- Start new nrand48. ------
unsigned long nrand48(
unsigned short state[3]
)
{
next(state);
return( ((unsigned long)state[2]) * 0x8000
+ ( ((unsigned long)state[1]) >> 1 )
);
}
----- End new {l,n}rand48. ------
----- Start rand48.h to be included in stdlib.h. -----
/* Copyright (C) 1998 Martin Strömberg. */
/* This function returns a double uniformly distributed in [0, 1). It
uses an internal state common to all the three functions drand48,
lrand48 and mrand48. */
double drand48(void);
/* This function returns a double uniformly distributed in [0, 1). It
uses the state supplied. */
double erand48(unsigned short state[3]);
/* This function returns an unsigned integer uniformly distributed in
[0, 2^31). It uses an internal state common to all the three
functions drand48, lrand48 and mrand48. */
unsigned long lrand48(void);
/* This function sets the internal state to the state supplied in
param[0], param[1] and param[2]. It sets the multiplier to
(param[5]*2^32 + param[4]*2^16 + param[3]) and the additiver to
param[6]. */
void lcong48(unsigned short param[7]);
/* This function returns a signed integer uniformly distributed in
[-2^31, 2^31). It uses an internal state common to all the three
functions drand48, lrand48 and mrand48. */
long mrand48(void);
/* This function returns an unsigned integer uniformly distributed in
[0, 2^31). It uses the state supplied. */
unsigned long nrand48(unsigned short state[3]);
/* This function sets the internal state to the supplied
state. Additionaly this function resets the multiplier and
additiver (possibly changed by a call to lcong48) to the default.
It returns the previous state. */
unsigned short * seed48(unsigned short state_seed[3]);
/* This function returns a signed integer uniformly distributed in
[-2^31, 2^31). It uses the state supplied. */
long jrand48(unsigned short state[3]);
/* This function sets the high order 32-bits of the internal state
used by the functions drand48, lrand48 and mrand48. The low order
16-bits are set to the arbitrary value 0x330e. Additionaly this
function resets the multiplier and additiver (possibly changed by a
call to lcong48) to the default. */
void srand48(long seedval);
----- End rand48.h to be included in stdlib.h. -----
- Raw text -