This is the mail archive of the guile@cygnus.com mailing list for the guile project.


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

Re: gsubr.c: C << operator question.


> I ran t.c through all the compilers I could find (HP-UX, SOLARIS,
> Digital UNIX, AIX, Visual C++); they all generated arithmetic 
> right shifts for the signed long value.  Did the standard get
> amended somewhere along the line?

The reason this is implementation-defined is because the concept
of "sign-extension" is implementation-defined.  For example,
it is not clear what it would mean on a system using
signed-magnitude representation of integers.  But since all
modern hardware uses 2's complement, and since all reasonable
compilers implement sign extension, in practice right shift
is is portable and well-defined.

One data point:  Java, which specifies a 2's complement
representation, does specify sign extension.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner