Sometimes the ability to test and/or set a specific bit is critical.
By Bruce Vining
While the vast majority of commercial applications do not need to be concerned with individual bit values, every once in a while you run across a support application-such as data collection or communications with another system-where the ability to test and/or set a specific bit becomes critical. Some languages, such as RPG and C, provide direct support for this type of operation. Other languages, with CL and COBOL coming quickly to mind, do not. Traditionally, I've seen some rather convoluted coding in CL and COBOL in order to work at the bit level. In this article, we'll look at a technique that greatly simplifies this type of work.