•  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-FileEVEN(x)
ODD(x)

x: aexp

This function checks whether the numerical expression x is even. EVEN() results
in TRUE for an even x and FALSE for an odd x.  Zero (0) is treated as an even
number.

    x     EVEN(x)
    Even  -1 (TRUE)
    Odd   0  (FALSE)
    Zero  -1 (TRUE)

This function checks whether the numerical expression x is odd. ODD() returns
the value -1 (TRUE), if x is odd and 0 (FALSE) if x is even. Zero (0) is
treated as an even number.

    x     ODD(x)
    Even  0  (FALSE)
    Odd   -1 (TRUE)
    Zero  0  (FALSE)

Example:

    x=2
    PRINT ODD(x),EVEN(-2),ODD(3*5),EVEN(-3*x)

--> The numbers 0, -1, -1, and -1 are displayed.

Memo: These functions convert all types to float format regardless.
      For integers only this will work:
      FUNCTION odd(int%)
        $F%
        RETURN BTST(int%,0)
      ENDFUNC