?
Solved

LZW - again

Posted on 2003-03-25
2
Medium Priority
?
226 Views
Last Modified: 2010-03-31
This is do with LZW.

I am trying to read in codewords as dictionary entries from a file, I read in 7 bits to start with, because 0 - 127
is the number of original entries in my dictionary ( i.e all the ascii values from 0 - 127 ), but when reading bits
from a file, i read each bit at a time but each bit ( up to 8 ) is stored in one byte, however if a number such as
one greater than 255 it will be 9 bits long, so that i need to be able to recognise this.  Note that when I compress
I have a current length variable that changes if the binary string that i am about to compress is greater than
its current length, if so i change current length to the size of that string, so that any binary strings (numbers)
processed after the change that are shorter in length than the current length are padded with 0's at the begining i.e

take the following
1001001                    //curlength variable is 7
1000101
10010101                //curlength variable is now changed to 8 as string length has changed
1111                 //but now we have a binary string of 4 length
 will become

1001001              //curlength variable is 7
1000101
10010101               //curlength variable is now changed to 8 as string length has changed
00001111               //curlength is no longer 7 so pad four 0's to make it the length of curlength variable


So when decompressing I will have some codewords padded with 0.

if i reach the number 127 at any point then i change the value of the curlength to 8, if
i reach the value of 255 at any time, then i change the value of the curlength 255 and so on, so that
even if get a code word that would be less than that then i know that it will be padded
with 0s at the begining.  The problem is is how do i know when to change as I am reading in 8 bits at a time
so that if a certain number is 9 bits what do I do?

I can post code if that will help, any help greatly appreciated.
0
Comment
Question by:imrama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
pronane earned 100 total points
ID: 8231248
0
 

Author Comment

by:imrama
ID: 8231251
thank you thats what I did, got it working.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question