Every variable used in the program has data type. A variable is created the first time it is referenced in your code, such as when you first set a value to it. As stated before, there are five types of variables. Each one has its own associated suffix to identify its type. It is a wise programmer who learns to use the appropriate data-type for the purpose they choose their variable, and to select the maximum storage (number of bytes) required.

String ( text$ ) – A string is QBasic’s term for storage locations pointed to by variables. Strings can contain numbers, but when they do mathematical formulas do not work on the numbers as they would with numbers stored in variables designed for numbers.
String length: minimum value = 0 characters ; maximum value = 32 767 characters

Integer ( number% ) – Integer variables are 2 bytes long and hold integers (numbers with no fractial part)
Integer length: minimum value = -32 768 numbers ; maximum value = 32 767 numbers

Long Integer ( number& ) -Long Integer variables are 4 bytes long and also hold integers.
Long integer length: minimum value = -2,147,483,648 numbers ; maximum value = 2,147,483,647 numbers

Single ( number! ) – Single-Precision variables are 2 bytes long (usually called Single) can handle numbers with a decimal point.
Single precision:
-positive: minimum value = 2 802597 * 10 ^ (-45) ; maximum value = 3 402823 * 10 ^ (38)
-negative: minimum value = -3 402823 * 10 ^ (38) ; maximum value = -2 802597 * 10 ^ (-45)

Double ( number# ) -Double-Precision variables are 4 bytes long (usually called Double) can also handle numbers with a decimal point.
Double precision:
-positive: minimum value = 4.940656458412465D-324 ; maximum value = 1.79769313486231D+308
-negative: minimum value = -1.79769313486231D+308 ; maximum value = -4.940656458412465D-324

Advertisements

Like this:

LikeLoading...

This entry was posted on Sunday, December 13th, 2009 at 12:14 am and is filed under QBasic. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.