Posts

Bit Arrays

Image
  A bit array is an array that compactly stores bits. A bit may represent the values 0 or 1, or it can be viewed as representing the values False or True. The C language has a somewhat loose interpretation of Boolean values, treating 0 as false and non-zero as true. The Ada programming language defines the Boolean type as the enumeration (False, True). Since that enumeration has only two values the Boolean type has only two position values. False is at position 0 and True is at position 1. C array indexing is connected to memory addresses. The typical smallest memory addressable value is a byte, which is typically 8 bits. Indexing a bit array, where each bit within a string of bytes has its own index value requires some bit gymnastics. The following C example is taken from https://www.sanfoundry.com/c-program-implement-bit-array/ Two functions are created. The function toggle_bit toggles the bit at the index value specified by the function’s second parameter. The function g...

Comparing Programming Languages Part 1 Scalar Ranges

 Overview It is often asserted that all general purpose programming languages can solve the same set of problems. This means that no one programming language has functional advantages over any other programming language. That assertion is only mostly true, which means it is false. For example, weakly typed languages can perform and make use of implicit type conversions while strongly typed languages cannot. Strongly typed languages must employ explicit conversions to achieve a similar effect. The purpose of this article is to begin discussing some of the things that are difficult in one commonly used language and relatively easy in another. Scalar Ranges Programming languages derived from Pascal syntax allow scalar types and subtypes to be defined by the programmer, while programming languages derived from C syntax do not allow the programmer to define scalar types or subtypes. In C++, for example, a class must be declared encapsulating the behavior of a scalar type w...