Changeset 1238


Ignore:
Timestamp:
2000-06-26T11:31:38+12:00 (24 years ago)
Author:
gwp
Message:

Additional explanation of hash problems in documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/hashfile/hashfile.cpp

    r1232 r1238  
    159159// and (z / 16 = 1) which means (z = 1).
    160160//
    161 // POSSIBLE CAUSE: Characters in the file are read one at a time; after each
     161// MAJOR REASON: suppose our prime number was 19.  Then, if we have a
     162// reasonably random distribution of numbers for which we are going to
     163// calculate (N % 19), we expect to get a roughly uniform distribution
     164// of remainders where the possible values are 0, 1, 2, 3... 18.  The
     165// problem is that 9 out of the 19 possible values (10,11... 18) start
     166// with the digit 1.  Thus our hascode will start with "01".
     167//
     168// ANOTHER PROBLEM: Characters in the file are read one at a time; after each
    162169// one is read it is prepended to the remainder, then the remainder is
    163 // recalculated on the string thus far seen.  I think the math here
    164 // may be just plain wrong.
    165 //
    166 // ANOTHER POSSIBLE CAUSE (this appears to be a genuine bug): Each character
    167 // from the file is read into  remainder at the most significant end, and
    168 // when that character is a zero you get a number like "01" which would
    169 // be considered larger than a number like "8" because it is longer (two
    170 // digits instead of 1). 
    171 //
    172 // These comments added by Gordon Paynter ([email protected]) on
    173 // June 23, 2000.  I didn't write this code, however.
     170// recalculated on the string thus far seen.  I am sure the math here
     171// is wrong - if I try calculating (111 mod 7) by the same algorithm, it
     172// simply does nor work.
     173//
     174// ANOTHER POSSIBLE PROLEM: Each character from the file is read into
     175// remainder at the most significant end, and when that character
     176// is a zero you get a number like "01" which would be considered
     177// larger than a number like "8" because it is longer (two  digits
     178// instead of 1). 
     179//
     180// These comments added by Gordon Paynter ([email protected]) in
     181// June 2000.  I didn't write any code, however.
    174182
    175183char *hashfile (char *filename) {
Note: See TracChangeset for help on using the changeset viewer.