[MAP Logo]

Materials Algorithms Project
Program Library



Subroutine MAP_UTIL_ODD

  1. Provenance of code.
  2. Purpose of code.
  3. Specification.
  4. Description of subroutine's operation.
  5. References.
  6. Parameter descriptions.
  7. Error indicators.
  8. Accuracy estimate.
  9. Any additional information.
  10. Example of code
  11. Auxiliary subroutines required.
  12. Keywords.
  13. Download source code.
  14. Links.

Provenance of Source Code

J.M. Wilkins,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge, U.K.

Top | Next

Purpose

To test if a number is odd or even.

Top | Next | Prev

Specification

Language:FORTRAN
Product form:Source code

SUBROUTINE MAP_UTIL_ODD(A,JODD)

REAL A

INTEGER JODD

Top | Next | Prev

Description

MAP_UTIL_ODD tests if the number A is odd or even. Integer arithmetic is used, and the test for the evenness of A is if INT(A/2) is equal to INT((A+1)/2).

Top | Next | Prev

References

None supplied.

Top | Next | Prev

Parameters

Input parameters

A - REAL
A is the number to be tested.

Output parameters

JODD - integer
JODD is set to 1 if A is odd, 0 if A is even.

Top | Next | Prev

Error Indicators

None.

Top | Next | Prev

Accuracy

Ideally, A should be an integer.

Top | Next | Prev

Further Comments

None.

Top | Next | Prev

Example

1. Program text

       REAL A
       INTEGER JODD
       READ (5,*) A
       CALL MAP_UTIL_ODD(A, JODD)
       IF (JODD .EQ. 0) GOTO 40
       WRITE(6,10) A
10     FORMAT(F8.2, ' is odd')
       GOTO 60
40     WRITE(6,20) A
20     FORMAT(F8.2, ' is even')
60     CONTINUE
       STOP
       END

2. Program data

3.0

3. Program results

3.0   is odd.

Top | Next | Prev

Auxiliary Routines

None.

Top | Next | Prev

Keywords

odd, even

Top | Next | Prev

Download

Download source code

Top | Prev


MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.

MAP Website administration / map@msm.cam.ac.uk

Top | Index | MAP Homepage Valid HTML 3.2!