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 />

● Logical<br />

● Functional<br />

6.4.1 Arithmetic Operators<br />

The following are the arithmetic operators recognized by GW-BASIC. They appear in order of<br />

precedence.<br />

OperatorOperation<br />

^ Exponentiation<br />

- Negation<br />

* Multiplication<br />

/ Floating-point Division<br />

+ Addition<br />

- Subtraction<br />

Operations within parentheses are performed first. Inside the parentheses, the usual order of<br />

precedence is maintained.<br />

The following are sample algebraic expressions and their GW-BASIC counterparts:<br />

Algebraic ExpressionBASIC Expression<br />

X–Z/Y<br />

(X-Y)/Z<br />

XY/Z<br />

X*Y/Z<br />

X+Y/Z<br />

(X+Y)/Z<br />

(X2) Y (X^2)^Y<br />

X YZ X^(Y^Z)<br />

X(-Y)<br />

X*(-Y)<br />

Two consecutive operators must be separated by parentheses.<br />

6.4.1.1 Integer Division and Modulus Arithmetic<br />

Two additional arithmetic operators are available: integer division and modulus arithmetic.<br />

Integer division is denoted by the backslash (\). The operands are rounded to integers (must be<br />

within the range of -32768 to 32767) before the division is performed, and the quotient is<br />

truncated to an integer.<br />

The following are examples of integer division:<br />

10\4 = 2<br />

25.68\6.99 = 3<br />

In the order of occurrence within GW-BASIC, the integer division will be performed just after<br />

floating-point division.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/Chapter 6.html (7 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!