Discussion:
somebody clarify encode and decode for me
(too old to reply)
u***@sample.net
2005-10-01 22:28:14 UTC
Permalink
After staring at the program for some time now, I still don't get the
exactly what the encode or decode does. The description is pretty much
"Encode functions - both really easy" in the file. I don't remember the
paper saying much about it. The main part seems to be dealing with
BitWriter. BitWriter is implemented by FileBitWriter. And all it seems
to do is write Bytes into the outputstream. So I'm encoding a symbol to
the output file each time I call encode? Writebit calls on writebyte,
I'm guess I call writebit or writebits. But what do I send into
writebit? And what is the byte that its writing into the output? My
java notation is also a bit rusty now. What does "currentByte << 1 |
bit" mean? That is about as far as I go in understanding the method.
So can someone tell me if I'm on the right track and/or what is needed
to do this method properly? Thanks

-Howing
t3h j1mb0
2005-10-02 20:02:24 UTC
Permalink
<< is a left shift, so currentByte << 1 is a left shift by 1 (or,
essentially multiplying by 2). | is a bitwise OR, so it does a bitwise
OR on each bit of currentByte and bit. Since the bottom bit of
currentByte will be a 0 after the left shift, it is essentially
concatenating the value of bit onto currentByte.
-Jimbo
Post by u***@sample.net
After staring at the program for some time now, I still don't get the
exactly what the encode or decode does. The description is pretty much
"Encode functions - both really easy" in the file. I don't remember the
paper saying much about it. The main part seems to be dealing with
BitWriter. BitWriter is implemented by FileBitWriter. And all it seems
to do is write Bytes into the outputstream. So I'm encoding a symbol to
the output file each time I call encode? Writebit calls on writebyte,
I'm guess I call writebit or writebits. But what do I send into
writebit? And what is the byte that its writing into the output? My
java notation is also a bit rusty now. What does "currentByte << 1 |
bit" mean? That is about as far as I go in understanding the method. So
can someone tell me if I'm on the right track and/or what is needed to
do this method properly? Thanks
-Howing
Loading...