QBasic Tutorials: QBasic for Beginners - Chapter 5
Quick View
QBasic Tutorials: QBasic for Beginners, Chapter 5 - More about Variables with QBasic: Types of Variables.
Author: Maxim Kakitsev
Created on 2001-03-26
Chapter V: More about Variables
So far you know that there are string variables (for holding text) and numeric variables (for holding numbers). But numbers can be very different, and in QBasic there are some different types of numeric variables:
Type of a variable | The number it can hold | Example of a number | Example of a variable |
---|---|---|---|
INTEGER | A whole number, from -32,768 to 32,767 | 5 | a% |
LONG INTEGER | A whole number, from more than -2 billion to more than 2 billion |
92,345 | a& |
SINGLE PRESICION | A number with up to 6 digits after the decimal point | 3.725 | a! |
DOUBLE PRESICION | A number with up to 15 digits after the decimal point | 3.1417583294 | a# |
As you see, those types of variables have a special symbol as part of their names:
% | INTEGER | The SINGLE type of variable is the most widely used in QBasic, and you don’t have to stick the ! symbol to it. If you put a variable without any symbol, QBasic will know that this is a SINGLE PRESICION variable. |
& | LONG | |
! | SINGLE | |
# | DOUBLE |