17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

Chapter 6<br />

Constants, Variables, Expressions and Operators<br />

After you have learned the fundamentals of programming in GW-BASIC, you will find that you<br />

will want to write more complex programs. The information in this chapter will help you learn<br />

more about the use of constants, variables, expressions, and operators in GW-BASIC, and how<br />

they can be used to develop more sophisticated programs.<br />

6.1 Constants<br />

Constants are static values the GW-BASIC Interpreter uses during execution of your program.<br />

There are two types of constants: string and numeric.<br />

A string constant is a sequence of 0 to 255 alphanumeric characters enclosed in double quotation<br />

marks. The following are sample string constants:<br />

HELLO<br />

$25,000.00<br />

Number of Employees<br />

Numeric constants can be positive or negative. When entering a numeric constant in GW-BASIC,<br />

you should not type the commas. For instance, if the number 10,000 were to be entered as a<br />

constant, it would be typed as 10000. There are five types of numeric constants: integer, fixedpoint,<br />

floating-point, hexadecimal, and octal.<br />

Constant Description<br />

Integer Whole numbers between -32768 and +32767. They do not contain<br />

decimal points.<br />

Fixed-Point Positive or negative real numbers that contain decimal points.<br />

Floating-Point Constants Positive or negative numbers represented in exponential form<br />

(similar to scientific notation). A floating-point constant consists of<br />

an optionally-signed integer or fixed-point number (the mantissa),<br />

followed by the letter E and an optionally-signed integer (the<br />

exponent). The allowable range for floating-point constants is<br />

3.0×10 -39 to 1.7×10 38. For example:<br />

235.988E-7=.0000235988<br />

2359E6=2359000000<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/Chapter 6.html (1 of 12)28/03/2004 21.29.00

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!