Re: Binary -> ASCII Converter (and bug i found)

From: Chris Gilbert (chris@buzzbee.freeserve.co.uk)
Date: 05/23/00


Michael Gallagher wrote:

[snip]

> P.S. The bug i found was in the sprintbits() function in the ascii code,
> one of the checks was:
>
> if (vektor & 1)
>
> and i think it should be
>
> if (vektor & (1 << i))

if you look at the full loop:
  for (i = 0; i < 64; i++) {
    if (vektor & 1) {
      *outstring = flags[i];
      outstring++;
    }
    vektor >>= 1;
  }

vektor is being moved to the right, so you're comparing it 1 bit at a
time, and then shift it right. Then again if you've not got vektor being
shifted right then you would need to do what you had ;)

Cheers,
Chris


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT