1: /*
   2:  *	This routine rolls ndie nside-sided dice.
   3:  */
   4: 
   5: # define    reg register
   6: 
   7: # ifndef vax
   8: # define    MAXRAND 32767L
   9: 
  10: roll(ndie, nsides)
  11: int ndie, nsides; {
  12: 
  13:     reg long    tot;
  14:     reg unsigned    n, r;
  15: 
  16:     tot = 0;
  17:     n = ndie;
  18:     while (n--)
  19:         tot += rand();
  20:     return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie;
  21: }
  22: 
  23: # else
  24: 
  25: roll(ndie, nsides)
  26: reg int ndie, nsides; {
  27: 
  28:     reg int     tot, r;
  29:     reg double  num_sides;
  30: 
  31:     num_sides = nsides;
  32:     tot = 0;
  33:     while (ndie--)
  34:         tot += (r = rand()) * (num_sides / 017777777777) + 1;
  35:     return tot;
  36: }
  37: # endif

Defined functions

Defined macros

MAXRAND defined in line 8; used 1 times
  • in line 20
reg defined in line 5; used 5 times
Last modified: 1982-06-09
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2362
Valid CSS Valid XHTML 1.0 Strict