Category Archives: Bit-Twiddling

Floating Point Representation

Back in the days when I was in middle school, I started to develop a strong preference for “nice” and “short” numbers, such as 0.1. One likely reason was that any math problem in school was designed to yield a … Continue reading

Posted in Bit-Twiddling, Math, Uncategorized | | Comments Off on Floating Point Representation

Swapping Variables

Many algorithms, including the world-famous Euclidean, require to swap the values of two variables. So you probably know the following principle. int x = 8; int y = 123; int tmp = x; x = y; y = tmp; However, … Continue reading

Posted in Bit-Twiddling, Information Theory, Uncategorized | Tagged , , , , | Comments Off on Swapping Variables

The X-Factor (OR The Power of XOR)

Once upon a time, a girl (non-computer scientist) had bought two pieces of cake for coffee. She asked her nerdy boy-friend: ‘Do you want this one or that one?’ He said ‘Thanks!’ and he quickly moved both pieces onto his … Continue reading

Never waste your memory! (Huffman Encoding)

In Morse code, a simple “dit” (.) represents the letter e, while a more complex sequence “dah-dit-dah-dah” (-.–) represents the letter y. As you probably know, the occurrence of e is significantly higher than the occurrence of y in most … Continue reading

Posted in Bit-Twiddling, Information Theory, Uncategorized | | Comments Off on Never waste your memory! (Huffman Encoding)

Parity

Data transfer inevitably threatens data integrity. It does not matter whether you save and restore files on your hard disk or you transmit data over long distances. Bits can always get twisted by interfering electric and electromagnetic fields. TCP/IP uses … Continue reading

Posted in Bit-Twiddling, Uncategorized | Tagged , | Comments Off on Parity