Well.. I'm triying to do a file compressor, and I need to read each byte and convert it to decimal, is the number of bites on a byte 8? or it can change depending on different things?
Well.. I'm triying to do a file compressor, and I need to read each byte and convert it to decimal, is the number of bites on a byte 8? or it can change depending on different things?
Check CHAR_BIT from <limits.h>I'm triying to do a file compressor, and I need to read each byte and convert it to decimal, is the number of bites on a byte 8? or it can change depending on different things?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The number of bytes in a byte is one: ALWAYS. And no, not all bytes are created equal. Some have 8 bits while others have 7 or even 12.
That is self-evident, though I believe that by "bites" lautarox meant "bits", otherwise the real question is when lautarox had his/her last meal that he/she has to resort to eating bytesThe number of bytes in a byte is one: ALWAYS.
However, the C Standard guarantees that bytes will be of at least 8 bits.And no, not all bytes are created equal. Some have 8 bits while others have 7 or even 12.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Mmm.. my plan was to convert an 8 bits, a supposed byte, to decimal, and give it a reference number, like this, for example, 64 = 1, another byte, 68 = 2, so 1+2 equals 3, so I give that two bites a reference number that is 3, and then I output it into a file reducing the original size..
No arguments there. It does not guarantee a constant size though. Which is why laserlight mentioned CHAR_BIT. In any event, I know "bites" meant "bits" but I am just being picky. Oh and lautarox, remind me about your other code. I keep forgetting to upload it to you and its not on this machine.Originally Posted by laserlight
I am not sure how that is supposed to work. How would you know that 3 means the byte pair (64, 68) and not (68, 64)?Mmm.. my plan was to convert an 8 bits, a supposed byte, to decimal, and give it a reference number, like this, for example, 64 = 1, another byte, 68 = 2, so 1+2 equals 3, so I give that two bites a reference number that is 3, and then I output it into a file reducing the original size..
Have you searched the Web for compression algorithms?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Read up on Huffman encoding. I think you will be pleasantly enlightened.
Well.. huffman encoding is based on prediction, I want my own creation =P, about knowing the byte pair, i can have numbers for each pair..
Thinking a little bit more, the size of the byte won't be a problem, because I stiil can read, convert and then read the conversion again..
Last edited by lautarox; 10-16-2008 at 01:40 PM.
Actually, you can still use variable Huffman encoding. There are better forms of compression for what you are describing though. Such as (God why can't I think of the name of it... its used in ZIP files.... guh. I will have to google it since I am drawing a blank for some reason). You can use a sliding window to reference previous instances of a block of data. LZ compression, there we go. Jesus. I didn't need to google it guys, I was just having a blond moment.