delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1996/10/14/00:46:44

From: akyol AT stanford DOT edu (Bora Akyol)
Subject: Failure to generate uniform r.v.s
14 Oct 1996 00:46:44 -0700 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <3.0b35.32.19961014000728.00919bb0.cygnus.gnu-win32@wireless.Stanford.EDU>
Mime-Version: 1.0
X-Sender: akyol AT wireless DOT Stanford DOT EDU
X-Mailer: Windows Eudora Pro Version 3.0b35 (32)
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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
akyol AT stanford DOT edu

mailto:akyol AT stanford DOT edu
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019