Casting Bit Magic

Pt. 1 Binary Representation and Endianness

Introduction

This article began as an explanation of the “fast inverse square root algorithm” found in the source code of Quake 3 by id Software. While working on the article and receiving feedback I realized that I would better split the article in a small series about binary representation and the floating point type. We will begin at the basics of bit representation and ending the series with some nice bit trickery with the floating point format. The goal of the article is that beginner level programmers can understand the lower level workings of their machine. I do sincerely hope I have included enough material that also the more experienced programmer will enjoy the content. So here is the first entry!

Continue reading “Casting Bit Magic”

Enough! Why rand() cant compress!!!

Unless you are born an information theory genius, at some point during your programming learning you might have considered the following hypothesis:

A file is a sequence of bytes. If I could find the appropriate seed for srand(), surely I could generate the file, just by successively calling rand() % 256? Therefore I could represent the file with just the seed and the expected file length.

Continue reading “Enough! Why rand() cant compress!!!”