1

Hey this is my first question on SE, I'm very nervous. I have searched for an answer to this and done some experimenting(hacked together some java code) and I can't seem to figure out whether or not it would be possible to turn any file into an equation that represents the decimal representation of the machine code that makes up a file.

example:

  • take in a file
  • turn into binary
  • calculate the decimal representation
  • turn number into a equation that could be easily saved or written down.

Assuming I'm coding in C, does anyone know how to produce the decimal representation of large binary numbers?

zentikiti
  • 11
  • 1
  • 1
    What are you trying to do? Your question doesn't make much sense as it is. – xxbbcc Nov 12 '14 at 22:19
  • I'm trying to think of a way to compress a hard drive into a equation so that transferring large amounts of data doesn't take so much time. Also if you wanted to wipe your drives you could turn it into an equation and later use another computer to rebuild your system bit by bit. – zentikiti Nov 12 '14 at 22:24
  • So your question is how to compress a file? – mafso Nov 12 '14 at 22:24
  • I just want to know if it's possible to turn a large binary number into a equation working with base10 numbers that could be easily written down or saved elsewhere. – zentikiti Nov 12 '14 at 22:28
  • Sounds like a novel idea, you'll likely have to implement this yourself. You'll definitely need a big number library to start with. – Seventoes Nov 12 '14 at 22:32
  • Before you get too deep into your implementation, you might want to prototype it by compressing an arbitrary 64-bit number (`unsigned long long` or `uint64_t`) into an equation. At any rate, you can find suggestions for an arbitrary precision library [here](http://stackoverflow.com/questions/2568446/the-best-cross-platform-portable-arbitrary-precision-math-library). – indiv Nov 12 '14 at 23:07
  • I don't understand why you need to convert to a decimal representation at all. What's the point in that? Also, what you are asking is equivalent to asking "how do you compress a file"? Because compressing binary bits is the same as compressing decimal digits. – JS1 Nov 12 '14 at 23:44
  • The reason I wanted to use base 10 instead of another base is that its human readable. Its easier to write a algorithm for doing math on base 10 numbers than base 2, for me. – zentikiti Nov 13 '14 at 00:11
  • So if I gave you a base 10 number with a million random digits, what are you going to do with it? Don't worry about turning a binary file into a base 10 number. Just create a file containing a large base 10 number to start with. The interesting part is what are you going to do with that base 10 number? Do you have an idea in mind? – JS1 Nov 13 '14 at 02:04
  • I'm still working out a algorithm for doing this. But something like taking long number, making the number of digits n and using the nth root or something to make the equation small enough to right down or save in a small txt file. Then when you wanted to recreate that file/volume just expand the equation/convert to binary and re-write to storage medium. – zentikiti Nov 13 '14 at 21:39

1 Answers1

1

The answer to your question is "sure!" Any binary data could be encoded as an arbitrarily long number, and it's always possible to find multiple equations that would represent that number.

I suspect the underlying question you're asking is whether doing such a thing would be smaller than the original file itself. If your source file happened to contain, for example, the string "10000000000", this could be represented compactly as 10^10, saving a bunch of bytes.

The answer to whether this can be done in general is "no". The fundamental limitation of representing information in a more compact format is described by Shannon's Theory of Information. (see Wikipedia Article 'Information Theory' It says, in a nutshell, that the more entropy is in data, the less it is possible to represent that information in a smaller format. Existing compression algorithms, including your idea to represent data as an equation, relies on the source data having predictable patterns within it. Trying to compress an arbitrary sequence of random numbers, for example, just can't be done.

brycem
  • 563
  • 3
  • 9
  • Can you write a specific number more than one way in a single string of binary? – zentikiti Nov 12 '14 at 23:25
  • Sure. You can use sums, powers, logarithms, or any other mathematical operations. But you're the one inventing this new method of data representation. – brycem Nov 13 '14 at 00:06
  • No I thought every decimal number had a unique binary representation. if not the whole thing is shot. – zentikiti Nov 13 '14 at 00:08
  • I misunderstood what you were asking, zentikiti. You can always create a representation where every distinct file can be represented by a single, distinct number. There are multiple ways you could do that representation, but it doesn't matter to your problem. If you can find a way to create a compact equation for every possible integer, then you can use it to represent files. – brycem Nov 13 '14 at 00:15
  • or you could simply use one of the zip/compress utilities to shrink the file to a minimum size, where the original file can be restored from the zip'd/compress'd string. – user3629249 Nov 13 '14 at 05:48