I want to make a file compression program
how can i replace with binary values less than 8 bit???
like a == 00001
b == 00010
...
how to work on these bits like adding 3rd bit etc??
plz help me
I want to make a file compression program
how can i replace with binary values less than 8 bit???
like a == 00001
b == 00010
...
how to work on these bits like adding 3rd bit etc??
plz help me
yeah i knw bitwise functions..
i want to say that i want to assign 0001 to a then how can i do that
or u can say i want to replace abc to 001.010.100 and then again replace it with abc
how can i replace a with 001 and futher??
i can't get it..i m a beginner.. can you plz explain this or can give me a link to the tutorial plz ???
man i have studied the bitwise operator & for AND operation to bit | for OR and ~ for COMPLEMENT..
but i this will still remain 8 bit i want to make a == (some 3 bit)
3 bits only have 8 combinations so you can only represent 8 letters. And you seem to be ignoring the 000 combination, which is a waste. Anyway, you'd need at least 5 bits (32 combinations) to represent 26 letters, and that's without distinguishing between upper and lower case.but i this will still remain 8 bit i want to make a == (some 3 bit)
You can turn 'a' into 000 by simply subtracting 'a' from it. So that part's easy. The problem is to "pack" the bits into bytes, etc. That will require bit-shifting, which are the << and >> operators, plus the | operator.
If you really want to do this right, you might want to look into something called Huffman coding.
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss
yeah i knw that.. i was just giving an example well thanks for the repply
There are no datatypes less than 8 bits (in modern reality).
To pack things smaller, you need to do things like packing three characters in two bytes.
Lets say you decide to represent A, B, and C as the following series of bits:
A:00000
B:00001
C:00010
To pack these into two bytes, the bits go like this:
00000000 01000100
So then you write out just those two bytes. This is very similar to how 16-bit colour data is stored. There are three colour channels and each is stored in 5 bits (or sometimes 6 for green to use that extra bit).
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
k sry msut nott hav bin mind-reedin goood todaay
Still Huffman coding, and related systems, are interesting for people with functioning brains.
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss
size = 2 . which means is storing value 00000000 00000001
and i want it to store 00001
help me plzz!!
Code:#include <iostream> using namespace std; int main() { short int a=0; a |= 1; cout << a << sizeof(a) ; return 0; }
You don't understand. You cannot make variables smaller.
Pay more atention to my example, perhaps try and implement that.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"