Skip to Main Content
Due to the recent acquisition by IBM, the Adabas & Natural Ideas Portal does not contain ideas from products ApplinX and EntireX any longer. Please refer to the IBM Ideas Portal for these products from now on (IBMid required). Existing content will be migrated during the next few weeks.
Status Future consideration
Workspace Natural for z/OS
Created by Philippe Van Coppenolle
Created on Aug 8, 2023

Function "ODD()"

If you want to know if a number is odd or even, you can do the following now:

IF #I <> #I / 2 * 2 THEN ... END-IF

This takes however quite a bit of CPU, but it can already by simplified by following declarations:

1 #I (I4)
2 #I_ODD (L)

The test can then be written as:

Because internally there is being tested on the rightmost bit.

This is easy for integers, it is just a TM (test under mask). And for packed and float numbers, a test on the rightmost bit of INT(number) should be made.

This idea should be valid for all platforms, like the similar function in PASCAL and its derivates.

Use Case See example in description