Small nit. When I brought up canonical values and the testing
methods, I never said -1. I said "all ones." It is more proper to
say (in C) ~0 (and I can't find the unary element function for bit
complement in F90). This works for both two's complement and one's
complement machines, and is more correctly aligned with the intent
(assuming 0 is represented by all zeros).
To the poster who claimed machines can generate 1 as a constant easier
than -1, that may have been true in the distant past, but all modern
architectures I know of have a variety of ways to generate -1 or ~0
just as efficiently as +1.
Date: Sun, 27 Mar 2005 17:09:56 -0700
From: James Giles <[log in to unmask]>
...
Logical stored as -1 and 0 easily converts to INTEGER -1 and 0.
Your fallacious assumptions are still showing.
...
The bottom line is, and this is repeated information, the language
doesn't specify what the internal representation of LOGICALs
are. It shouldn't. On most hardware I have any interest in at
all, neither implementation (-1 vs. 0 or 0 vs. 1) is produced
directly be compare instructions. In many cases that interest
me, -1 vs. 0 is a better choice for the canonical internal rep
than 1 v.s 0. In an even larger set of interesting environments,
interpreting *any* negative as .true. and *any* non-negative as
.false. is even better. Using the least significant bit is also the
least interesting option.
|