|
-
August 2nd, 2002, 01:38 AM
#1
How accurate will this be....
[ccode]
float CompressDwordToFloat(unsigned long);
unsigned long DecompressDwordFromFloat(float lfValue);
float CompressDwordToFloat(unsigned long dwValue) throw()
{
double lfTemp = (double)dwValue / 16777216;
return static_cast<float>(lfTemp);
}
unsigned long DecompressDwordFromFloat(float lfValue) throw()
{
double lfTemp = lfValue;
lfTemp *= 16777216;
unsigned long dwTemp = static_cast<unsigned long>(lfTemp);
if (lfTemp - (double)dwTemp > 0.5)
{
++dwTemp;
}
return dwTemp;
}
[/ccode]
Every value I test works. Are there any problems with this? Since every value I've tested 'decompressed' correctly, I don't see why it would have any troubles. I wish to cut a buffer 'in half' and then compress it normally with zlib or other compression method.
Last edited by JamesSchumacher; August 2nd, 2002 at 01:44 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|