Squares

General FreeBASIC programming questions.
Locked
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Squares

Post by angros47 »

Albert.

Stop. Please, STOP. We tried to explain it in every possible way that it can't work. There is a very well written wikipedia article here https://en.wikipedia.org/wiki/Lossless_ ... imitations that explains why it can't work.

You don't believe it? Fine. Keep trying, if you want. But please, stop coming here whining that it doesn't work. It is immature.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I think Zlib has some AI built-in to stop you from compressing data..
If you get compression , it outputs some bad data and emails the Zlib people with the code...

Maybe it's just my paranoia??? Maybe i need my meds adjusted???
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Squares

Post by angros47 »

Are you serious?

Are you suggesting that developers of a compression software would deliberately hijack their own software so it won't work?
Are you suggesting that it will steal your code, although you admitted that your code never worked? (so why anyone would want it?)
Are you suggesting that, despite it being open-source, no one ever noticed such a backdoor in zlip?

Well, I suggested that it's either paranoia, or trolling
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I found a formula that compresses 87% , on the first loop...
I'm going over it real carefully , to see if it's for real... ( i might have a coding error?? )

I inputted 100,000 bytes and it outputted 112,577 bytes , and compressed it to , 12,983 bytes...

Now to work on the decompression....

So far , if i find a formula that compresses, i posted it
If it doesn't compress , then i don't post it...

You guys were getting tired of me posting compression code , that couldn't be decompressed..
So , i won;t post it , till i get the decompression done...

I think I'll call it "Redditt-Zip".. So everyone knows my name.. It' s a real simple , half byte formula..
I'll work on the decompression tomorrow...
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Squares

Post by angros47 »

Albert, do you accept a bet?

Something like: if your formula works, I'll stop replying to you, forever. If your formula can't be decompressed, you will stop posting anything about compression, forever. Deal?
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@angros47

When i started programming , i had several first objectives...

==========================================================================================================
My first code posted to the FB forum was about making circles...See "Circles"
I had forgotten my Atari Formula for making circles , The Atari computers with Atari Basic didn't have a circle function..
I had created a formula for the Atari , to make circles without sines and cosines , but had forgotten it over the years..
It still evades my memories... It used 0 to 90 degrees... with lines drawn by the dimensions of the circle vs. the dimensions of the screen.
==========================================================================================================

With my desires:

First , was to program a huge number calculator , accomplished!! ( look on the projects section of the forum for Big-Calc )
Me and Richard form Australia , worked on "Big-Calc" together....

Second , was to make a totally unsolvable encryption , accomplished!! ( look on the projects section of the forum for "Vari_Cyph" )

Third , was to write a font-creator , accomplished!! ( look on the projects section of the forum for "Picto-Font" )
I've yet to make an editor for the "Picto-Font" , you can create font characters , but you can't do anything with them at the moment...
I want to make a "Picto-Font" editor , so you can embed font chrs into a document...

Fourth , was to create a new spoken language , I'm still not done with that yet...
But you can find the beginnings of it , by searching the general forum for "Huh-Yuh"

Fifth , was to create data compression , so you can zip a zip file and make it smaller..
I'm still , hard at work , on it , working 6 to 10 hrs a day trying different formulas...
When i get compression accomplished , I'll post it ( like the other goals ) , to the projects section of the forum....

==========================================================================================
I can't promise to stop posting compression related stuff,
but i will promise , to not post source code for an unfinished compression...
I'm an ameture programmer , i might need some help with coding questions.. like with any other code posted here...
The whole idea of having a forum , is for people to ask questions and post code , and report bugs..
I've been asking questions...But exceeded the limit i guess..
So I'll work on my own , only asking questions about coding stuff..

My latest attempt , ( about it , posted just above ) has many duplicates in the output ,
But their is a map for ( greater than ) and ( less than ) and ( equals )... So all three possibilities are accounted for...
The compression code itself , doesn't compress , the "Map" is the same length as the input , so it expands by the input len \ 8..
But Zlib somehow compresses it 87%
==========================================================================================

I also took a snippet of D.J.Peters circle code for OpenGL
And turned it into a nice little ScreenSaver
See the projects section of the forum for "Morphius"
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I looked and looked
and found a coding error ...
After fixing the error , it expands by 500 bytes on the first loop..instead of compressing 87%
I found the error while writing the decompression.. I was getting all "0's" for the output... so it compressed down to the size of the map 12,940 bytes.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Richard

If i have a 9 bit binary value and mod it by 128 , how would you recover the value , when you know the 9'th bit is set??
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Post by Richard »

Albert wrote:@Richard
If i have a 9 bit binary value and mod it by 128 , how would you recover the value , when you know the 9'th bit is set??
It depends what you mean by the 9'th bit.

You could "value OR 128" to set the byte MSB again.
But why delete two bits with "value MOD 128" if you are going to immediately put one back again? If you don't put it back immediately, you will have to store it somewhere else.

Also, you could simply use “value AND 127” to remove the multiples of 128, without needing to execute the MOD which requires the remainder of an integer divide in the CPU.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Richard

The 9'th bit , is the leftmost bit... with the rightmost bit being bit 1...

If you mod it by 128 , how would you recover the value..
Knowing it's 9 bits and the leftmost bit is set..

Is there a way to recover the number??

And could you explain the and 127 ?? can you use it instead of mod to get the value back??

The following compresses , but how do you recreate the input??
if len( n1 ) = 8 then
n2 = "1" + mid( n1 , 3 ) + left( n1 , 2 )
n2 = bin( val( "&B" + n2 ) mod 128 )
map+= "1"
end if
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Post by Richard »

When you “value MOD 128" you destroyed two bits, they had values of 256 and 128 making a total of 384.
If you only remember one of them, then you cannot restore the original value because you have lost the other.

"value OR 384" will set the two MSBs, what you call bits 8 and 9.
"value MOD 128" keeps only the 7 lowest bits, it does not restore anything.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Richard

n2 = "1" + mid( n1 , 3 ) + left( n1 , 2 ) , compresses

n2 = "1" + mid( n1 , 4 ) + left( n1 , 3 ) , expands
n2 = "1" + mid( n1 , 2 ) + left( n1 , 1 ) , expands

With the topmost formula , how do you turn the 9 bits , into something 8 or less bits long? MOD 256 doesn't work..

with n1 = 8 bits..
n2 = "1" + mid( n1 , 3 ) + left( n1 , 2 )
n2 = bin( val( "&B" + n2 ) and 256 ) , compresses by 99%
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Post by Richard »

@albert
If “anything” is a positive integer then;
Anything to the power of 0 is one. 2^0 = 1.
Anything to the power of 1 is itself. 2^1 = 2.
Anything to the power of 2 is the square. 2^2 = 4.
Anything to the power of 3 is the cube. 2^3 = 8.

That is why the bits in a binary number are numbered starting with 0.
The LSB of a byte is bit number 0, which is worth 2^0 = 1.
The MSB of a byte is bit number 7, which is worth 2^7 = 128.

Code: Select all

Print "bit", "vaue"
For i As Integer = 0 To 9
    Print i, 2^i
Next i
So don't refer to the 9'th bit of a binary number, refer to bit 8, which has a value of 2^8 = 256.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Richard

with n1 = 8 bits.. = "1000-0000"

n2 = "1" + mid( n1 , 3 ) + left( n1 , 2 ) = 9 bits = "1" + "00-0000" + "10"
n2 = bin( val( "&B" + n2 ) and 256 ) , compresses by 99%

How do you adjust the the second formula ( AND 256 ) , so the output is 8 bits or less? and is recoverable ??
Richard
Posts: 3096
Joined: Jan 15, 2007 20:44
Location: Australia

Re: Squares

Post by Richard »

I think when you say something “compresses” you actually mean that part of it is “deleted”.
Your belief that you can “uncompress” is really a belief that you can magically “undelete” what has been destroyed.
Locked