•  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-FileADD(x,y)
SUB(x,y)
MUL(x,y)
DIV(x,y)
MOD(x,y)

x, y: iexp

ADD(), SUB(), MUL(), DIV(), and MOD() offer quicker integer arithmetic with
Polish notation.

These functions can replace more usual expressions thus:

    Instruction  Corresponds to
    ADD(x,y)     x+y
    SUB(x,y)     x-y
    MUL(x,y)     x*y
    DIV(x,y)     x/y or x DIV y
    MOD(x,y)     x MOD y

Since these function uses integer arithmetic, any decimal places are ignored.
These function can be nested at will. This method of notation is known as
'Polish'.

See also ADD, SUB, MUL, DIV, and MOD.

After the following program segment is run...

    x%=5
    y%=4
    ADD y%,3
    z%=SUB(x%,3)

... x% will have the value 5, y% the value 7, and z% the value 2.

Examples:

    DEFINT "a-z"
    x=4
    y=ADD(x,x)                !y becomes equal to 8
    z=SUB(x,2)
    PRINT y,z,ADD(x,MUL(y,2))

--> The numbers 8, 2, and 20 appear on the screen.

    DEFINT "a-z"
    x=2
    y=MUL(x,3)                 !y becomes equal to 6
    PRINT 7,DIV(8,x),MOD(11,4) !MOD(11,4) is equal to 3

--> The numbers 6, 4, and 3 appear on the screen.

    DEFINT "a-z"
    x=5
    y=ADD(SUB(x,2),MUL(3,4))
    PRINT y,DIV(8,MOD(14,4))

--> Displays the numbers 15 and 4.