• Hi Bonnie,

    Usage of bitmasks was very common and useful up until the seventies, when memory footprint off applications and data came at a premium. If you have to run a program on your home computer with only 32 KB (yes, KILObytes) of memory -half of which was reserved for video memory, keyboard memory, and firmware-, you get to appreciate the value of combining multiple values in a single bytes. And when data has to be stored on a casette recorder with a recording andd playback speed of 300 bits per second, you get to apppreciate the savings even more.

    Same for professional development. Those computers often had a whopping 64 kB to their disposal - still good reason to save a few bytes. Storage was on floppy disks, or, for the lucky, on hard disks. One of the earliest hard disk bragged a storage capacity of 5 MB, and came at a price of $ 50,000. Try telling your boss: "The good news is, I decomposed the bit mask in the main file for orders into seperate fields; the bad news is, we need to add a second 5 MB hard disk..."

    In modern computer development, bit masks are still used quite often in low-level languages like assembly language, or C. These languages are commonly used for the most performance-critical bits of applications, and since many processors have instructions in their instruction sets for handling bit masks, using bit masks can yield a performance boost.

    But in modern third-and-higher generation languages, bit masks have no place at all. And in databases, they should be outright forbidden.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/