
Recent Posts
Recent Comments
Archives
Categories
Meta
Category Archives: BitTwiddling
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 BitTwiddling, Math, Uncategorized
Tagged double, exponent, float, floating point, ieee754, mantissa
Swapping Variables
Many algorithms, including the worldfamous 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 BitTwiddling, Information Theory, Uncategorized
Tagged bittwiddling, c, logic, variable, xor
The XFactor (OR The Power of XOR)
Once upon a time, a girl (noncomputer scientist) had bought two pieces of cake for coffee. She asked her nerdy boyfriend: ‘Do you want this one or that one?’ He said ‘Thanks!’ and he quickly moved both pieces onto his … Continue reading
Posted in BitTwiddling, Uncategorized
Tagged bittwiddling, logic, masking, xor
Never waste your memory! (Huffman Encoding)
In Morse code, a simple “dit” (.) represents the letter e, while a more complex sequence “dahditdahdah” (.–) 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 BitTwiddling, Information Theory, Uncategorized
Tagged binary tree, compression, data, entropy, huffman, information
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 BitTwiddling, Uncategorized
Tagged c, parity
Masking
In this posting I’m going to explain a bittwiddling technique called masking. It is used to extract (and alter) specific bits in a word of bits, for example a byte. You might be familiar with IP subnet masks in network … Continue reading
Posted in BitTwiddling, Uncategorized
Tagged assembly, bittwiddling, c, masking, microcontroller