For Programmers: Free Programming Magazines  


Home > Archive > Fortran > December 2005 > Re: Kind of NOT integer constant









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: Kind of NOT integer constant
robin

2005-12-18, 3:56 am

"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


Sponsored Links







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

Copyright 2008 codecomments.com