Computers for Smart People by Robert S. Swiatek - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

            balance signed decimal(6.2)

introduces two new keywords,

            signed

and

            decimal.

Since the account balance could be negative at times and it does involve cents as well as dollars, we need to spell that out. The variable

            signed

allows for negative as well as positive numbers, while

            decimal(6.2)

indicates that the field has 6 digits to the left of the decimal point and 2 to the right. If the balance happened to be $16.20, it would be on the file as

            00001620,

and because the field has a sign, the program knows that this is the positive value of

            16.20.

It knows exactly where the decimal point is even though it is not on the file.

            This structure will be used in the first program that we consider and we’ll be using other structures as we need them. This will enable us to read a file and access specific fields in each record. The keyword

            structure

merely says we have a piece of a file, namely a record, and this record itself consists of different things. These are nothing more than the fields that make up the record. We can access the entire record or individual elements of it.