Data Types

          Qbasic has 5 'primitive' Data Types, all listed in the table below. Each data type has a specific range of values that it is capable of handling. The main purpose of this is so that you can choose the type of value that you need for your computations. If you only need your variable to be between 0 and 100, you obviously wouldn't use the largest avaliable data type, because it is a waste of memory.

  Data Types:

Type Name: Symbol: Max value Min Value
String           $ 32,767 characters 0 characters
Integer           % 32,767 -32,768
Long Integer           & 2,147,483,647 -2,147,483,648
Single Precision           ! +/- 3.402823 x 10^38 +/- 1.401298 x 10^-45
Double Precision           # +/- 1.7976931x10^308 +/- 4.940656x10^-324

          The CONST keyword is used to indicate the binding of a value to a specific variable for the duration of the program, example:
          CONST pi = 3.141592654
If you try to change the value of pi you will get an error like: "Duplicate definition"

          The final data type is the user defined data type, which is essentially a data type that you create out of the above types. The construction and use of these can be found inside of the tutorial.


Notes on Data Types:
          1) One thing that you may want to note is that the double precision is just an estimate of any value that you give it so it may not always be accurate. The same is true for the single precision, but it is not quite as bad. I reccomend that you try these and see what comes up, just to get an Idea of what is going on with them.
          2) Another issue to be addressed here is the notation. The help file in QBasic uses a different notation than I do here. I used normal scientific notation. If you are not familiar with that, all that it means is x10^number is just the number of decimal places, a (-) sign in front of the 'number' means that the number is a fraction, and the larger the negative number the smaller the fraction.

    Back         Main Tutorial Page         Next