Jack Pot’s Computer Literacy Lessons: Data Types

Real devices aren’t perfectly copying what Boolean algebra describes in theory. Electronics knows neither dual numbers nor values like TRUE or FALSE. Who builds electronic devices, distinguishes between high voltage (H) and low voltage (L), but this already is the best approximation, which can be done if the goal is to make a device, which is able to calculate. So even complete processing units deliver only outputs of H and L, although several of them. Processing units also accept inputs only as H or L.

But already the dual number system sprang from Gottfried Wilhelm Leibniz misunderstanding the Yì-Jīng (traditional: 易經 / simplified: 易经). The H and L of electronics fit much better to it. So H and L can be interpreted as one and zero, but also as TRUE and FALSE, on and off, and so on. So when you write an algorithm, then you must be aware that your interpretation of such a binary state (this is not the same as dual because the expression dual is in informatics exclusively used as a technical term for the number system on the basis two) isn’t the only possible interpretation. Especially a computer can’t know what you mean, so an algorithm, especially if it is for a computer program, must contain definitions of the types of the used data.

I already introduced the Boolean variables, which can only have the values TRUE or FALSE. If you want to use this type of variable in a computer program, then you have to specify that the variable is of the type Boolean. A computer program will only perform logical operations with Boolean variables and only classical mathematical operations with number variables and only print string variables. A computer program won’t print a variable containing a number! For a computer program, numbers aren’t represented by glyphs. For a computer program numbers are just numbers, completely abstract and even not defined well if defined only as numbers. If you want to show a number, whether on a screen or on a printout, then you must make it available in a variable of the type string.

Boolean variables and string variables are special types of variables. A computer normally is constructed for calculating something. Hence numbers are the most important data types. You now could presume that the number basis would have to be specified. But this is unnecessary because the computer can only calculate with dual numbers anyway. Each programming language assumes that you write in the decimal system and then automatically transforms the number into the dual system before passing it on. But the length of the number is a problem. Computer scientists arbitrarily decided that eight bits are one byte. (The original byte had only seven bits, but this soon proved to be too short.) This allows to represent two-hundred-and-fifty-six different values of a variable. Some programming languages allow to define a number variable of this size as the type byte or the type shortint (a short integer number), but you won’t get far with that. Hence computer scientists decided that two bytes are called a Double and four bytes are called a Word. Some old programming languages require you do define these as data types (Double as integer and Word as longint for a long integer number) if you need a variable of an according length. But strings can need variables of an extreme length, so that they can contain whole texts. Hence pocket calculators can’t process text and the introduction of text editors required that variables could be of a rather indefinite length (although there are physical limits in reality). Modern programming languages hence know only variables of variable length, so you can confidently define a variable just as of the type integer, but you have to be cautious do not order any division because the result could be a non-integer number. Fractional numbers need a different data type. They usually are defined as float. Sometimes longer fractional numbers have to be defined as double. (The original idea for the Double was to allocate one byte for the part left of the decimal point and one byte for the part right of the decimal point.) Displaying a number on a screen sometimes is useful, so programming languages provide functions like converting a number into a string. But this can happen only when the programmer did think at calling this function in his algorithm. Computers aren’t able to understand anything and hence won’t do such things on their own! The attempt of displaying a number, whether float or integer, will only cause an error.

4 thoughts on “Jack Pot’s Computer Literacy Lessons: Data Types

Leave a comment