Wide Bit Fields

An on-off bit field is pretty common; you’ll find them all over. Also common are wide bit fields, which can hold values greater than one or zero. These wide bit fields are often mixed with single-bit fields making for a wonderful stew of binary data all held within a single integer value.
Continue reading

Bit Field Manipulation

The three basic bit manipulation operations are:

  • Set a bit (change its value to 1)
  • Reset a bit (change its value to 0)
  • Read a bit (determine whether it’s 1 or 0)

The standard C library lacks specific functions to carry out these bit manipulations, and I haven’t checked to see whether a third party library is available. That’s because you can easily code these operations on your own.
Continue reading

Brute Force Permutations

If Arthur C. Clarke’s story The Nine Billion Names of God were true, then it seems rather pointless to plow through all 9,000,000,000 permutations to find one matching name. In fact, the exercise is more like a brute-force password cracking program than some celestial name search. What if the monks already knew the name? That would save time and effort.
Continue reading

Permutations

In his 1953 short story, The Nine Billion Names of God, Arthur C. Clarke writes of Tibetan llamas who seek to know all the names of God. They’ve been writing down the names for centuries, but upon the advent of the computer, they enlist western science to help them finish the task in days. You can complete the same task with your computer and the C programming language, but in hours instead of days.
Continue reading