Skip to main content
76 votes
Accepted

How do you debug a binary format?

For ad-hoc checks, just use a standard hexdump and learn to eyeball it. If you want to tool up for a proper investigation, I usually write a separate decoder in something like Python - ideally this ...
Useless's user avatar
  • 12.9k
40 votes
Accepted

What are the complexities of a binary search?

The full term for this is "Time Complexity" and you'll want to use that if you are searching. This is a core concept in computer science. I am not going to attempt to explain it in detail ...
JimmyJames's user avatar
  • 31.1k
13 votes
Accepted

Binary data formats, how to make ensure you can read different format versions?

It seems to me that the simplest solution is to make your version header unambiguous and make sure that the old format can never look like it has a format header, you simply look for it. If it's not ...
JimmyJames's user avatar
  • 31.1k
10 votes

How do you debug a binary format?

The first step to doing this is that you need a way to find or define a grammar that describes structure of the data i.e. a schema. An example of this is a language feature of COBOL which is ...
JimmyJames's user avatar
  • 31.1k
10 votes

Binary data formats, how to make ensure you can read different format versions?

Your old format starts with an 8-byte "size" element (probably a 64-bit long). If that's the file size in bytes (what I guess), it most probably never exceeded 100 GByte, meaning 2^37. So, if you ...
Ralf Kleberhoff's user avatar
8 votes
Accepted

Why is the bitwise AND of 1 and any even number equal to 0?

First, looking at decimal In base 10, we can easily determine the parity of an integer (whether it is even or odd), by looking at the parity of the last digit: If a base 10 numbers ends in 0, 2, 4, 6,...
Alexander's user avatar
  • 5,205
8 votes

Binary data formats, how to make ensure you can read different format versions?

The convention format version ID, everything else is good because it gives maximum flexibility for the format. In your case the version ID isn't right at the front but at a fixed offset. This slightly ...
amon's user avatar
  • 136k
8 votes

What are the complexities of a binary search?

The average time is smaller than the worst-case time, because the search can terminate early, but this manifests as a constant factor, and the runtime is in the same complexity class. Using a linear ...
Simon Richter's user avatar
7 votes
Accepted

In C++, how is signed integer stored?

In C++, how is signed integer stored? The C++ specification does not prescribe any particular storage representation for signed integers on the actual hardware level. An implementation is free to ...
Jörg W Mittag's user avatar
6 votes

How do you debug a binary format?

ASN.1, Abstract Syntax Notation One, provides a way of specifying a binary format. DDT - Develop using sample data and unit tests. A textual dump can be helpful. If in XML you can collapse/expand ...
Joop Eggen's user avatar
  • 2,639
6 votes
Accepted

How to prove that given binary files are compiled from provided source code?

how can I be 100% sure that the given binary files are compiled from the given source code? The only way is to compile it yourself using the exact same environment that has been used to build the ...
mouviciel's user avatar
  • 15.5k
6 votes

What are the complexities of a binary search?

The data in this table is not telling you how long a search takes. Its telling you how the time and storage may scale with the amount of data being searched. Lets take a real world example. Suppose ...
Stilez's user avatar
  • 507
5 votes

Best method for Pattern Matching on Binary String?

Reformulated problem statement You have some huge binary content and you'll have to scan it for a set of thousands of bit patterns. The main problem is that the bit patterns can happen anywhere in ...
Christophe's user avatar
  • 82.3k
5 votes

Do decimal equivalents to binary number values hold significance in software programming?

My question is: Is there any significance to the fact that the number we had to use to set that bit happens to be 64? There is exactly the same significance to the fact that the ascii character we had ...
candied_orange's user avatar
5 votes

Why is the bitwise AND of 1 and any even number equal to 0?

To see why, let's start by finishing the AND operation and viewing the results in binary: 00101 (5) 00001 (1) -----& 00001 (1) 00100 (4) 00001 (1) -----& 00000 (0) When we AND a variable (...
Erik Eidt's user avatar
  • 34.8k
4 votes

How compiled code works?

There are a few pieces to the puzzle of executables. First, obviously, is the code itself. To understand this, you need to understand your target CPU's instruction set, including its binary encoding. ...
Sebastian Redl's user avatar
4 votes

How are floating point representations (say single precision for instance) able to represent more numbers than what a 32 bit memory allows?

How are floating point representations (say single precision for instance) able to represent more numbers than what a 32 bit memory allows? They're not able to, and they don't. There are still only 2^...
Alexander's user avatar
  • 5,205
3 votes

How do binary numbers interact with the CPU and cause some action to take place?

CPUs have instruction sets, add two numbers, jump forward 3 instructions, if this is true run the next instruction, if not skip and instruction etc https://en.wikipedia.org/wiki/...
Ewan's user avatar
  • 84.6k
3 votes

How to prove that given binary files are compiled from provided source code?

The keyword you'd want to put in the search engine here is "reproducible build". What this means is that whenever you build the same version of the software under a well known configuration, ...
Lie Ryan's user avatar
  • 12.5k
3 votes

Why is the bitwise AND of 1 and any even number equal to 0?

I'm not sure whether I'm covering the same ground as the existing answers, but cast your mind back to learning Hundreds, Tens, and Units in primary school. That system, in which there are ten ...
Steve's user avatar
  • 12.7k
3 votes

How are floating point representations (say single precision for instance) able to represent more numbers than what a 32 bit memory allows?

The short answer is it can't, and it doesn't. A range of 1038 for a 32 bit float corresponds to an 8 bit exponent (⌈log2(1038)⌉ = 127, which takes 7 bits, plus one for the sign bit), leaving just 24 ...
outis's user avatar
  • 1,171
3 votes

How do you debug a binary format?

Other answers have described viewing a hex dump, or writing out object structures in i.e. JSON. I think combining both of these is very helpful. Using a tool that can render the JSON on top of the ...
Carl Walsh's user avatar
3 votes

What is this numeral system notation?

If you see 1010 written without any qualification, you don't know if that's: Decimal 10 written in base 2 (binary) Decimal 30 written in base 3 (ternary) Decimal 68 written in base 4 (quarternary) [.....
Philip Kendall's user avatar
3 votes
Accepted

How do you represent a negative floating point in two's complement?

So as promised, I asked the technical support, they gave me a first answer saying that the decimal value is separate from the integer value and that it shouldn't be taken as two's complement (...
Nuz's user avatar
  • 51
2 votes
Accepted

What's the best approach for using Git for a project containing a largish binary database (4 GB, 4000 files)?

Best approach I can think of is: do not put the large binary files directly into version control, instead, put them in a folder with a version number on a network share (or whatever kind of file ...
Doc Brown's user avatar
  • 221k
2 votes

Can I distribute binaries of my GPLv3 software?

If you are the sole copyright holder, then you can do whatever you like. You might commit a GPL violation, but only the copyright holder can hold you responsible for this. If you are the sole ...
gnasher729's user avatar
  • 49.4k
2 votes
Accepted

Can I distribute binaries of my GPLv3 software?

In practice, if you distribute (e.g. by providing it on some web site) a binary of your code, you'll better also provide (e.g. on the same web page) a source tarball of it (exactly the one you used ...
Basile Starynkevitch's user avatar
2 votes

Do decimal equivalents to binary number values hold significance in software programming?

Most things can be used in multiple ways. For example, coins can be used as screwdrivers sometimes. But when a coin is used as a screwdriver, it doesn’t matter that the coin could also be used to buy ...
Lawrence's user avatar
  • 657
2 votes

Do decimal equivalents to binary number values hold significance in software programming?

Binary, octal, decimal, hexadecimal are only different means to express the same number. So it’s not about a special significance, it’s just that 0100 0000 in binary, 64 in decimal and 0x40 in ...
Christophe's user avatar
  • 82.3k
2 votes

Do decimal equivalents to binary number values hold significance in software programming?

No, there is no meaningful relationship between the decimal and binary notations of the numbers. One is base 10 and the other base 2 and ten is not a power of two. The reason we use base-10 Arabic ...
Michiel's user avatar
  • 21

Only top scored, non community-wiki answers of a minimum length are eligible