This is the mail archive of the gcc@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: portable signed right shift


On 28-Mar-2001, dewar@gnat.com <dewar@gnat.com> wrote:
> <<Do you know of any C89 implementations for which integer division does not
> truncate towards zero?
> >>
> 
> It is unlikely at this stage. Historically there were machines on which
> division truncated away from zero for negative numbers (the natural
> mathematical definition where dividing by two divides numbers into
> those with a remainder of 0 and those with a remainder of 1). For
> example, the KDF-9 was like this (for sure), and I am fairly sure
> the ICL series machines were also like this.
> 
> But Fortran required truncation towards zero, and with the supremacy of
> Fortran over Algol in the commercial world, European machines fell in
> line with US machines which had always truncated towards zero.
> 
> Note that thye question is not about C89 implementations but about machines,
> if there *were* a machine with the old European definition, then the change
> in C99 would be mega-painful :-)

My question was about C89 implementations.
I knew the stuff about machines and Fortran -- that was a big
part of the C99 committee's rationale for changing this.
But I was wondering if there were any C89 implementations
which didn't always use the machine division instruction;
e.g. perhaps there might be some optimization advantage
to rounding differently in certain cases?.

(I should have asked "Do you know of any C89 implementations for which
integer division does not _always_ truncate towards zero?".)

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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