•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-File+ - * /
^
DIV \
MOD
+n -n

n: number

These arithmetic operators link two numerical expressions and produce a number.
This number can then be used as part of another expression, assigned to a
variable, printed out with PRINT, etc. The operators + and - are also used as
signs to indicate whether numbers are positive or negative (-1, +2, etc.).

x+y      Produces the sum of the numbers x and y (addition)

x-y      Produces the difference of the numbers x and y (subtraction)

x*y      Produces the product of the numbers x and y (multiplication)

x/y      Produces the quotient of x divided by y (division)

x^y      Produces x raised to the power y (exponentiation)

x DIV y  Results in a fast integer division of x by y

x\y      The backslash '\' character is an alternative form of DIV

x MOD y  Produces the remainder of the division of x by y.

+ provides the value n with a positive sign, unless it was negative, in which
case it is left as it was.

- provides the value n with a negative sign. If is was positive, it is treated
as negative and vise versa.

See also MOD().

The following relations are equivalent:

    x DIV y = TRUNC(x/y)
    x MOD y = x-y*TRUNC(x/y)

(TRUNC() is the Truncate function.)

Example:

    13 DIV 4  produces 3
    13 MOD 4  produces 1

Memo: Additional reading related to the compiler, see sections
      'Integer Division' and 'Integer Multiplication'.