Branch: Tag:

2018-03-30

2018-03-30 19:35:52 by Tobias S. Josefowitz <tobij@tobij.de>

ADT.CritBit.BigNumTree: off by one error (removed)

Due to an off-by-one error the last limb of bignums was never compared.
This resulted (sometimes) in bignums comparing equal inside of the tree.

25: Inside #if defined(CB_PRINT_CHAR)
  #ifdef CB_PRINT_CHAR    CB_PRINT_CHAR(buf, key.str, i.chars);   #else -  string_builder_sprintf(buf, "(%d, %d) b: ", i.chars, CB_WIDTH(s)); +  string_builder_sprintf(buf, "(%d, %d) b: ", i.chars, CB_WIDTH(key.str));    -  for (i.bits = 0; i.bits < CB_WIDTH(s); i.bits++) { +  for (i.bits = 0; i.bits < CB_WIDTH(key.str); i.bits++) {    string_builder_sprintf(buf, "%d", CB_GET_BIT(key.str, i));    }    string_builder_putchar(buf, ' ');
53:    cb_size i;       for (i.chars = 0; i.chars < key.len.chars; i.chars++) { -  for (i.bits = 0; i.bits < CB_WIDTH(s); i.bits++) { +  for (i.bits = 0; i.bits < CB_WIDTH(key.str); i.bits++) {    string_builder_putchar(buf, CB_GET_BIT(key.str, i) ? '1' : '0');    }    }