Introduction to BASIC   Calculation

Four basic mathematical operations
The four operations addition, subtraction, multiplication and division are denoted by using + - * / , respectively.
Example. A program that calculates 3×2 and 3÷2, and displays the results of them.

10 PRINT 3*2,3/2
20 END


Exponentiation and powers
ab, a to the b-th power, is denoted by a^b.
Example. A program that finds 2 raised to the fifth.

10 PRINT 2^5
20 END


Priority of operation
Power operation has higher priority than multiplication and division, which have higher priority than addition and subtraction.
Operations of the same priority are performed from left to right.
Example.

10 PRINT 1+3*2^3
20 PRINT 2^3^3
30 END

The result of the above is as follows.
25
512
Note that 2^3^3 is appreciated as (2^3)^3.

Complicated expressions
Parentheses can be used to indicate the priority. Parentheses are always '(' and ')', even if they are nested.
Example

10 PRINT ((2+3)*4)^2
20 END


Square Root
The non-negative square root of a number can be calculated by a SQR function.
Example.

10 PRINT SQR(2)
20 END


Refer to Supplied Functions

[Note]
The Full BASIC standard demands the accuracy of power operations, SQR-functions and any other numerical supplied functions to be equivalent to that of the four operations.