Home » Questions » Computers [ Ask a new question ]

Binary repetition

Binary repetition

In binary up to how many times can a 1 (one) or a 0 (zero) be repeated.

Asked by: Guest | Views: 228
Total answers/comments: 2
Guest [Entry]

"You're asking about binary strings. In a general sense, there is no limit to the number of 0's or 1's that can appear in sequence. That is, an infinitely-long string of 0's is valid binary.

You're also asking about binary formats. Data in a computer aren't just random binary strings; they're formatted in a particular way so that specially-designed machines called computers can process them, either as information (like an MP3) or as instructions (like winamp.exe), or even as transmission encodings (like the encodings used in USB or Ethernet).

In a practical sense, you won't find arbitrary-length strings of 0's or 1's in executable code. Transmission encodings, if they aren't synchronized via another method, may insert extra bits after a certain number of data bits, so arbitrary-length strings won't be found there either. Data formats can be more flexible, and some will allow long strings of 0's or 1's, but formats like MP3 require regular markers (again, for synchronization), so even an MP3 of silence won't contain all 0's.

So: could a binary string contain a sequence of 9 zeroes? Sure, it's quite possible, and probably very common. Could a particular binary format contain that? Maybe. But it's impossible to tell without specifying what format."
Guest [Entry]

"It's exactly equivalent to asking how many zeros, or ones, or twos etc you can have in a row in a decimal number. As many as you want, why would there be a limit?

There is, of course, a limit to the maximum size that any particular variable/file/disk can hold, but that is a practical matter which is secondary to the maths.

More specifically, if you asking how likely is a particular sequence of zeros in an MP3 file, because that its a compressed file format, it is less likely as the length of the sequence increases. You'll find many pairs of zeros, but fewer runs of three, and even fewer runs of 4 etc. The compression routines are specifically looking for patterns so are removing them to reduce the file size, and replacing them with a reference to the pattern - as an approximate explanation of file compression."