For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2005 > Re: printing logical variables as "true" and "false"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: printing logical variables as "true" and "false"
Paul Van Delst

2005-11-29, 7:01 pm

Nestor Grion wrote:
> Hello
> In Matlab:
>
> F => 0
> T => 1
>
> 0 => F
> else => T


Slightly off topic, but in IDL:

F => Zero and even values (e.g. -4, -2, 0, 2, 4, etc)
T => Odd non zero values (e.g. -3, -1, 1, 3, 5, etc)

(which I can't stand, btw.)

I much prefer the Fortran logicals .true. and .false. It's quite clear what it means. 0
and 1 have different meanings in different contexts/languages, e.g. "exit 0" from a Bourne
shell script is a good result, whereas "exit 1" (or some other integer) flags an error. By
the logic where F=>0 and T=>1, I would think that "exit 0" == "exit false" and it
indicates an error. With Fortran I don't have to worry about that.

cheers,

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com