What is “two’s complement”?

Two’s complement is a clever way of storing integers so that common math problems are very simple to implement. To understand, you have to think of the numbers in binary. It basically says, for zero, use all 0’s. for positive integers, start counting up, with a maximum of 2(number of bits – 1)-1. for negative … Read more

What are important points when designing a (binary) file format? [closed]

Take a look at the PNG spec. This format has some very good rationale behind it. Also, decide what’s important for your future format: compactness, compatibility, allowing to embed other formats (different compression algorithms) inside it. Another interesting example would be the Google’s protocol buffers, where size of the transferred data is the king. As … Read more

Is it possible to program in binary?

Of course. It’s more commonly called machine code. It’s basically assembly language without the mnemonic devices. Someone who knows assembly very well could program in machine code with additional effort, referring to opcode listings (e.g. x86) as needed. Would I do it? No. Even assembly is only useful in rare circumstances, and there’s no reason … Read more

How do you convert a fraction to binary?

In university I learned it this way: Multiply by two take decimal as the digit take the fraction as the starting point for the next step repeat until you either get to 0 or a periodic number read the number starting from the top – the first result is the first digit after the comma … Read more

Advantage of 2’s complement over 1’s complement?

The primary advantage of two’s complement over one’s complement is that two’s complement only has one value for zero. One’s complement has a “positive” zero and a “negative” zero. Next, to add numbers using one’s complement you have to first do binary addition, then add in an end-around carry value. Two’s complement has only one … Read more

How do I create binary patches?

Check out bsdiff and bspatch (website, manpage, paper, GitHub fork). To install this tool: Windows: Download and extract this package. You will also need a copy of bzip2.exe in PATH; download that from the “Binaries” link here. macOS: Install Homebrew and use it to install bsdiff. Linux: Use your package manager to install bsdiff.

Tools to help reverse engineer binary file formats

Here are some tips that come to mind: From my experience, interactive scripting languages (I use Python) can be a great help. You can write a simple framework to deal with binary streams and some simple algorithms. Then you can write scripts that will take your binary and check various things. For example: Do some … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)