|
| "Steven G. Kargl" <kargl@troutmask.apl.washington.edu> wrote in message
news:dnvhla$rnb$1@gnus01.u.washington.edu...
> The crux of the matter is that the function does not return -1. It
> returns 2**32-1=4294967295 (ie, a 32-bit number with all bits set).
NOT(0) returns an integer having all bits set.
> On a two's complement computer with a 32-bit signed integer, this just
> happens to be -1
This far is correct.
However, the returned value is of type integer whose value is -1.
> when the returned value is written into the
> memory location of a 32-bit signed integer. When the returned value is
> written into the memory location of a signed 64-bit integer, it happens to
> be 4294967295.
The returned value is -1 on a machine that represents negative numbers
in twos complement form.
[on a machine that represents negative numbers in ones complement
form, the value is -0]
PROGRAM TEST
IMPLICIT NONE
INTEGER, PARAMETER :: W8 = SELECTED_INT_KIND (1)
INTEGER, PARAMETER :: W16 = SELECTED_INT_KIND (3)
INTEGER (KIND=W8) :: I = 0
INTEGER (KIND=W16) :: J = 0
PRINT *, BIT_SIZE(I), BIT_SIZE(J), BIT_SIZE(0)
PRINT *, BIT_SIZE(NOT(I)), BIT_SIZE(NOT(J)), BIT_SIZE(NOT(0))
PRINT *, NOT(I), NOT(J), NOT(0)
END PROGRAM TEST
8 16 32
8 16 32
-1 -1 -1
|
|