precision and the double holds what is called double precision. To simplify, we will use double when the data is a real number. The char data type holds one Unicode character. This may be a letter or number. It may also be a punctuation character. If the value is a character, choose and use the char data type. The boolean data type can be either of the reserved words true or false. This data type has no specified size. A boolean variable might be used to test whether a condition is true or false. Note that boolean, true, and false all start with a low- ercase letter. Choosing the correct type for each data item is important to finding the solution to a problem. The data type must be large enough to store all possible values for the data, but not too large as to waste memory and CPU time. For example, when YouTube set up a counter for the number of views for a video, it defined the counter as an int. Given that an int can store a value of more than two billion, it seemed to be a good choice. However, YouTube did not an- ticipate the overwhelming popularity of “Gangnam Style,” which soon exceeded two billion views. As a result, YouTube needed to redefine the view counter as a long. This data type can store a value of more than nine quintillion (9E18)! The new value should be sufficiently large for the near future, at least. Another example of choosing the wrong size for data is what was called the Y2K (Year 2000) Problem. In the early days of computing, memory was limited and expensive. COBOL programmers cleverly chose two digits to hold the year. For example, 86 meant 1986. What the programmers did not foresee was that their programs would still be used many years later when the first two digits of the year would change. When the year changed to 2000, the two-digit value would become 00. This made it seem that 1999 (99) was 99 years later than 2000. The problems this could cause were many. For example, it was predicted the computers that controlled elevators would calculate that the time for maintenance was long past and, therefore, permanent- ly hold the elevators on the bottom floor. Also, bus, train, and airplane schedules that depend on dates would be upended because January 1, 2000 would appear to be January 1, 1900. Because of these potential problems, some people predicted a disaster when the year would change to 2000. Companies called COBOL programmers out of retirement to redefine the year and update the mountains of data already stored in two digits. It was a large undertaking, but because of those efforts, on January 1, 2000, the Time Square New Year’s ball fell into a calm and orderly business-as-usual new day. Typed and Untyped Languages A typed language is any one that uses explicit data types. An untyped lan- guage is a language that does not have a type system or all variables are consid- ered one type. Most high-level languages have a typing system. A type system is viewed as a set of constraints that are verified at compile time. Some typed languages include Java, C++, Visual Basic, Python, Perl, and Ruby. Untyped lan- guages do not make you define the type of a variable. JavaScript is an example of an untyped language. This means that a JavaScript variable can hold a value of any data type. For the most part, untyped languages, such as most assembly languages, allow any operation to be performed on any data, which are generally considered to be sequences of bits of various lengths. The current programming philosophy is type-driven languages are pre- ferred. They are more efficient and correct. If the data is structured, that infers a structure for the program. FYI The boolean data type is named after the English mathematician George Boole who invented Boolean logic. Boolean logic is the foundation of digital computer logic. Copyright Goodheart-Willcox Co., Inc. Chapter 4 Variables 77