PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs323] Flushing
Date: Thursday, 12 Nov 2020, 22:41:19


    > Message Posted By: Unknown
    >
    > When do we use flushBits? Is it supposed to be done at the start and end
    > of every code execution, or should it also be done at other times?

As I posted earlier:

  Subject: Re: [Cs323] flushBits
   
      > Message Posted By: Unknown
      >
      > When do you need to call flushBits()?
   
  Suppose that stdin contains one character, and that
  encode is running in Stage 3 and has assigned a code to
  the empty string.  Then encode will call putBits() to
  write one 9-bit code to stdout.  putBits() can only
  output the high-order 8 bits of this code and thus must
  save the low-order bit for the next call.  But unless
  encode calls flushBits() (or does something equivalent),
  there will not be a next call and the low-order bit will
  never be output.

--Stan-
PREV INDEX NEXT