Subject: Failure to generate uniform r.v.s
From: [email-masked] (Bora Akyol)

14 Oct 1996 00:46:44 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Sender: [email-masked]
X-Mailer: Windows Eudora Pro Version 3.0b35 (32)
Original-To: [email-masked]
Original-Sender: [email-masked]

Please see attached function:
double rand_u(int stream) {

  long zi,lowprd,hi31;
  long end_res;
  extern long zrng[];
  
  zi=zrng[stream];
  /*  printf("ZI: %d\n",zi);*/
  lowprd= (zi & 65535) * MULT1;
  printf("LOWPRD:%d\n",lowprd);
  hi31= (zi >> 16) * MULT1 + (lowprd >> 16);
  printf("HI31:%d\n",hi31);
  zi = ( (lowprd & 65535) -MODLUS) + ( (hi31 & 32767) << 16 )+(hi31 >>15);
  printf("ZI: %d\n",zi);
  if (zi <0)  zi+=MODLUS;
  lowprd = (zi & 65535) *MULT2;
  hi31= (zi >> 16) * MULT2 + (lowprd >> 16);
  zi = ( (lowprd & 65535) -MODLUS) + ( (hi31 & 32767) << 16 )+(hi31 >>15); 
  if (zi <0)  zi+=MODLUS;
  zrng[stream]=zi;
  printf("ZI: %d\n",zi);
  end_res= (( (zi >> 7 | 1) +1) / 16777216.0);
  printf("%d\n",end_res);
  return (double) end_res;
}

For some reason this function works on Linux, BSD and Suns using gcc
and does not work in gcc-win32.
All of the files compile fine with no errors on all systems.
It is the last line that end_res is assigned to that returns a negative value
in long which is not possible since zi is positive and the divider is
positive.

Any info will be appreciated please email replys personally to
[email-masked]

mailto:[email-masked]
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".