Hello Guys;
Albert Redditt here..
I was banned from the FB forum for posting compression formulas that didn't work..
I've finally got a working compression formula..
( !!~~YAHOO~~!! ) ( Recursive Lossless Random Data Compression )
Here's the compression loop..
dim as string m1 , m2
dim as ubyte in
for a as longint = 0 to len( chrs ) - 1 step 1
in = chrs[a]
if in >= 000 and in <= 031 then m1 = "0"
if in >= 032 and in <= 063 then m1 = "1"
if in >= 064 and in <= 095 then m1 = "2"
if in >= 096 and in <= 127 then m1 = "3"
if in >= 128 and in <= 159 then m1 = "4"
if in >= 160 and in <= 191 then m1 = "5"
if in >= 192 and in <= 239 then m1 = "6"
if in >= 240 and in <= 255 then m1 = "7"
m2 = oct( in mod 32 )
m2+= m1
chrs[a] = val( "&O" + m2 )
next
Can you un-ban me so i can post of the forum???
Attached Files
You pass the output "chrs" to a zip library and then keep looping until it can't get any smaller..
Compresses any size file down to 4800 bytes.
Hi Albert.
Let's keep this off the forum. There's no need to bother anyone else. You're probably going to ignore my message. Please don't be a jerk, actually read it. You're banned from the forum because you ignore EVERYTHING that anyone writes to you. Which makes it pointless for you to be on a forum.
Your compression loop contains a subtle bug. It looks like it reorders the bits of
chrs[a], moving the top 3 bits (value from 0 to 7) to the back. That can be written much more simply, and far, far more efficiently as:Learn what the bitshift operators
shlandshrand bitwise operatorsandandordo, they are very useful.Anyway, your bug is that the lines
should be
This bug meant that your compressor was NOT lossless. It is the reason that the compressor output kept getting smaller as it looped.
Your decompression function is unfinished, Please stop claiming to have a compressor if you don't have a decompressor.
But it is very simple to write. Here it is:
There are also two other bugs. Firstly you have an extra
loops-= 1above the decompression loop, which I deleted. Secondly, you need to replaceprint #1 , chrswith
put #1, , chrsbecause
printadds an extra newline.After these fixes, you have a working compressor and decompressor, and it actually outperforms zlib by 0.1% when compressing zlib.dll! Congratulations! Of course, it does not recursely compress any file down to almost nothing, because that is mathematically impossible. But preprocessing the file and then feeding it to zlib to improve the result IS a valid and very successful strategy. Work on that instead.
I've attached the fixed version of your program, and made it run on Linux as well as Windows. Enjoy!
Last edit: TeeEmCee 2023-05-06
Opps. I didn't post the actual "fixed" lines of code. I've edited my comment above. They should have been: