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.

Python conversion from binary string to hexadecimal

int given base 2 and then hex: >>> int(‘010110’, 2) 22 >>> hex(int(‘010110’, 2)) ‘0x16’ >>> >>> hex(int(‘0000010010001101’, 2)) ‘0x48d’ The doc of int: int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of … Read more

what is the best practice of distributing binaries from a github project? [closed]

As of December 11, 2012 the Downloads feature on GitHub is deprecated. The article Distributing large binaries recommends using an external service: We recommend Amazon S3 for storage paired with CloudFront for serving via CDN, or other services such as SourceForge. However, since 2d July 2013, you now can define a release. Releases, a workflow … Read more

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

Read and write to binary files in C?

Reading and writing binary files is pretty much the same as any other file, the only difference is how you open it: unsigned char buffer[10]; FILE *ptr; ptr = fopen(“test.bin”,”rb”); // r for read, b for binary fread(buffer,sizeof(buffer),1,ptr); // read 10 bytes to our buffer You said you can read it, but it’s not outputting … Read more

Why is base128 not used? [closed]

The problem is that at least 32 characters of the ASCII character set are ‘control characters’ which may be interpreted by the receiving terminal. E.g., there’s the BEL (bell) character that makes the receiving terminal chime. There’s the SOT (Start Of Transmission) and EOT (End Of Transmission) characters which performs exactly what their names imply. … Read more