Liberty BASIC Help Online

Mathematics
See also Numeric Variables, Mathematical OperationsTrigonometry, Numbers and Strings
 
Numbers and Numeric Expressions
Most mathematical operations in Liberty BASIC can be performed on literal numbers, numeric variables, or numeric expressions that consist of literal numbers, numeric variables, or both.  Functions that require a numeric input can also use any of these forms, as long as the expression evaluates to a number. Here is the ABS function used as an example:
 
print ABS(-2)'a literal number
 
x = 13
print ABS(x)'a numeric variable
 
print ABS(7-233)'a literal numeric expression
 
print ABS( x/13 )'a numeric expression containing a variable
 
 
Arithmetic
Arithmetic operators are as follows:
 
+addition
-subtraction
*multiplication
/division
^power
 
Examples:
 
print 2 + 3        'addition
 
print 6 - 2        'subtraction
 
print 4 * 7        'multiplication
 
print 9 / 3        'division
 
print 2 ^ 3        'power - (two to the third power)
 
 
print (4+2)*6^2    'multiple expressions are evaluated according to the following rules of order:
 
Order
Expressions are evaluated in this order:
 
( )expressions within parentheses are evaluated first
 
^exponents are evaluated next
 
*  /multiplication and division are evaluated next
 
+ -addition and subtraction are evaluated last
 
See also:
 
SIN
COS
TAN
ASN
ACS
ATN
ABS
EXP
LOG
HEXDEC
DECHEX$
INT
MAX
MIN
RND
SQR
VAL
STR$
USING
 
 


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/