Re: printing logical variables as "true" and "false"
- From: "James Van Buskirk" <not_valid@xxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 11:47:11 -0700
"Paul Van Delst" <Paul.vanDelst@xxxxxxxx> wrote in message
news:dmi229$1on$1@xxxxxxxxxxxxxxxxxxxxx
> 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.)
Actually, the DEC family of Fortran compilers did this, too.
The massive advantage of the LSB defining LOGICAL values like
this is that bitwise logical operations have the effect of
Fortran LOGICAL operations. I consider it probable that
many old-school compilers (i.e. ones that have roots predating
MIL-STD 1753) behave this way so as to permit masking
expressions. The difference in behavior becomes apparent
when mixed-language programming of bit-swizzling via
TRANSFER. One can get ugly results when Fortran processors
use the C-style (value of x is "x /= 0") int as boolean:
you can have both a and b evaluate as .TRUE., but a .AND. b
evaluate as .FALSE.
program logical_test
implicit none
logical a, b
a = transfer(1,a)
b = transfer(2,b)
write(*,*) a, b, a .AND. b
end program logical_test
Output with LF95 v. 5.70f:
T T F
Output with CVF v. 6.6C3
T F F
Output with g95 gcc version 4.0.1 (g95!) Sep 1 2005:
T T T
--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
.
- Follow-Ups:
- Re: printing logical variables as "true" and "false"
- From: Andy Mai
- Re: printing logical variables as "true" and "false"
- References:
- printing logical variables as "true" and "false"
- From: beliavsky
- Re: printing logical variables as "true" and "false"
- From: Richard E Maine
- Re: printing logical variables as "true" and "false"
- From: *** Hendrickson
- Re: printing logical variables as "true" and "false"
- From: Richard E Maine
- Re: printing logical variables as "true" and "false"
- From: Richard E Maine
- Re: printing logical variables as "true" and "false"
- From: *** Hendrickson
- Re: printing logical variables as "true" and "false"
- From: James Van Buskirk
- Re: printing logical variables as "true" and "false"
- From: Nestor Grion
- Re: printing logical variables as "true" and "false"
- From: Richard Maine
- Re: printing logical variables as "true" and "false"
- From: Ron Shepard
- Re: printing logical variables as "true" and "false"
- From: David Flower
- Re: printing logical variables as "true" and "false"
- From: Nestor Grion
- Re: printing logical variables as "true" and "false"
- From: Paul Van Delst
- printing logical variables as "true" and "false"
- Prev by Date: Re: printing logical variables as "true" and "false"
- Next by Date: Re: tape i/o
- Previous by thread: Re: printing logical variables as "true" and "false"
- Next by thread: Re: printing logical variables as "true" and "false"
- Index(es):