C Library Functions  - bool (3)

NAME

bool(3f) - [M_overload::LOGICAL] returns One if expression is TRUE, else returns Zero. (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

pure elemental integer function bool(expr)

    logical,intent(in) :: expr

DESCRIPTION

bool(3f) returns an integer 1 given a true logical expression.

OPTIONS

expr A logical expression

RETURNS

The result is a default INTEGER value of 1 if the expression is TRUE, and a 0 otherwise.

EXAMPLES

Sample usage:

   program demo_oz
   use M_overload, only: bool, zo, lt, le, eq, ne, gt, ge
   implicit none
      write (*, *) ’is 10 < 20 ?’, bool(10 < 20)
      write (*, *) ’elemental’, bool([2 > 1, 3 == 4, 10 < 5, 100 > 50])
      if (sum(bool([2 > 1, 3 == 4, 10 < 5, 100 > 50])) >= 2) then
         write (*, *) ’two or more are true’
      endif
   end program demo_oz

Results:

    > is 10 < 20 ? 1
    > elemental 1 0 0 1
    > two or more are true

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 bool (3) February 23, 2025
Generated by manServer 1.08 from cec0c904-4ab3-4a90-b181-4f5bc3dcfc15 using man macros.