Advertisement

A bit of a byte...

Started by May 30, 2000 10:42 AM
7 comments, last by abe_bcs 24 years, 4 months ago
How do I extract specific bits from a byte and then assign specific bits of a byte in C/++? It's for a compression format I've just thought of WHICH CAN COMPRESS RECURSIVELY! *sig deleted* Edited by - abe_bcs on 5/30/00 10:41:06 PM
/ // / |< <-
bool bitvalue(unsigned int data,char position)
{
return data&(1 << position);
}

void setbit(unsigned int *data,char position,char value)
{
if (value) *data/=(1 << position);
else *data&=~(1 << position);
}

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Advertisement
Dont'' most compression programs compress recursively?

E:cb woof!
E:cb woof!
with / I mean the bitwise logical OR

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
MP3 beating compression part 2?

Anyway, ga's code is correct, I'll post it as code-tagged code so it's easier to read.

bool bitvalue(unsigned int data,char position){  return data&(1 << position);}void setbit(unsigned int *data,char position,char value){  if (value)     *data/=(1 << position);   else     *data&=~(1 << position);}    



#pragma DWIM // Do What I Mean!
~ Mad Keith ~

Grrr, so this lovely forum turns all bitwise OR-s into slashes.. Sorry GA, guess you already new that, and guess I just made a useless post.


Edited by - MadKeithV on May 30, 2000 12:35:14 PM
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
I guess no one will believe me after ''MP3 beating compression''... I''ll put up the next post after the decompression and compression algorithms are coded.
Here''s what I''ll do - I''ll put up the decompression algorithm for download, then, anyone can send me any of their files, and I''ll send them back the same file, compressed, which can be extracted by the decompression program. You can send me an MP3, JPEG, ZIP, RAR... any file, I''ll compress it.
How''s that?
/ // / |< <-
Advertisement
Hmm have you tested for data inegrity? Actually I''m interested to see what you come up with....keep me posted.

"All work and no play makes Jack a dull boy." - The Shining
abe_bcs:
you just gotta promise: if you failed or realized that there was an error in your program, say it before people go nuts. and dont let this go like that stupi mp3-beating compression thread.

i once had an idea for a really really good compression method. i told it to my friends and they said just try it.
so i made the program and first i tested it with a 512byte random file and i came up with 6 or 8 bytes i guess.
then i tried the program on a 2mb zipped file and after 5 minutes of *compressing* i got a 4mb file back
so i gave up rightaway (and i didnt make an idiot of myself by lying after that)

- pouya
--------------
The trick to flight is to throw yourself at the ground and miss!!!
Listen, I don''t know anything about CRCs, integrity and stuff. I have no background in compression, I don''t even know how LZW works! This thing is damn simple, and I''m pretty sure it''ll work, but I don''t promise anything, except that you guys on GDNet will be the first to get the program.
/ // / |< <-

This topic is closed to new replies.

Advertisement