This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: RSHIFT


Tim Prince wrote:

> In 'info g77' it is pointed
> out that the result of RSHIFT() as implemented in g77 is undefined in cases
> involving signedness, and that you should use the standard function ISHFT()
> in such cases.  In your example, this changes the results you have marked.

Tim hits the nail on the head; from `intdoc.texi':

Currently this intrinsic is defined assuming
the underlying representation of [the variable undergoing the shift]
is as a two's-complement integer.
It is unclear at this point whether that
definition will apply when a different
representation is involved.

Because RSHIFT isn't a [Fortran 90+] Standard intrinsic, its semantics
are modelled according to what appears to be used most.  Hence RSHIFT
will shift in sign bits instead of zeros (as would be the case with
ISHFT(i,-2) because ISHFT is a Fortran 90 intrinsic with well-defined
semantics - i is interpreted as an unsigned string of bits).

Hope this helps - in addition to Tim's reply,

-- 
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]