Discussion Board
There are no previous messagesGo to the following message
Current Forum: Homework 4 General Forum
Date: Tue Oct 2 2001 8:35 pm
Author: Danish, Matt R. <mrd@cmu.edu>
Attachment: randomnumbers (16384 bytes)
Subject: Binary data

So, after attempting to compress a binary file I've discovered that the readByte method acts in an interesting manner. Since it returns a byte, one must cast it to int to use it as an array index. Apparently, while the byte type is only 8 bits, and the int type is 32 bits, the sign of the byte type is preserved when casting it to int. So reading in a byte value of '255' really is '-1' and casting it to int results in an array index of '-1'. I created a method to fix this, but I'm curious as to whether binary files (files containing ASCII characters > 127) will be included in the test suites. If so, people should be aware of this issue.

Also, for fun I went to random.org and picked up 16384 bytes of truely random atmospheric-noise data. It's quite incompressible, as expected, but I've attached it to this message if you'd like to give it a go.

Post response

There are no previous messagesGo to the following message
Current Thread Detail:
Binary data +Attachment      Danish, Matt R.      Tue Oct 2 2001 8:35 pm       
Re: Binary data      Lee, Peter      Tue Oct 2 2001 9:34 pm       
Re: Binary data      Danish, Matt R.      Tue Oct 2 2001 10:34 pm       
Re: Binary data      Lee, Peter      Tue Oct 2 2001 10:38 pm       
Re: Binary data      Cipriani, Jason A.      Thu Oct 4 2001 10:26 am       

Back to previous screen