From -8457356854909103204
X-Google-Thread: f78e5,c063db358aabf0d8
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news4.google.com!homer!news.glorb.com!news-spur1.glorb.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: Integer division specification
Date: Tue, 20 Feb 2007 12:05:32 CST
Organization: http://groups.google.com
Lines: 70
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1171810627.755597.115900@v45g2000cwv.googlegroups.com>
References: <n5u5t219ouhheqn399kchuhhrd3jm7er69@4ax.com>
   <k9odt25148b6olt421jip03kqqbcq4meo1@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1171810633 1642 127.0.0.1 (18 Feb 2007 14:57:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 18 Feb 2007 14:57:13 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: v45g2000cwv.googlegroups.com; posting-host=89.48.243.97;
   posting-account=0YhmiQ0AAABRDjD_6coNmBVB3rgPlaOq
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:5647

On 17 Feb., 20:37, Gennaro Prota <gennaro.pr...@yahoo.com> wrote:
> On Wed, 14 Feb 2007 09:25:30 CST, Gennaro Prota wrote:
> >Hi,
>
> >I was wondering if, as part of the synchronization with C99, the C++
> >standard is going to require truncation towards zero for integer
> >division or continue to allow the same choice as C90.
>
> Well, let me please do another attempt at getting a reply. I have a
> defect report concerning the specification of operator / and the
> proposed resolution would depend on whether truncation "towards -inf"
> is allowed or not.
>
> It would help everyone, not least the committee which would have to
> examine the DR, to know the answer to this (if it is already known
> :-)).

I'm sorry, that I can be only of limited help here, but even some
little help is better than nothing, I guess ;-)

I just read the current wording of C99 and the most recent draft for
C++. From what I read, I would deduce the following:

1) C99 (More exactly: I have studied 9899:1999 (E) for this), says
in 6.5.5/6:

"When integers are divided, the result of the / operator is the
algebraic
quotient with any fractional part discarded.87)"

with footnote 87:

"This is often called ''truncation toward zero''."

so indeed C99 demands truncation toward zero.

2) Opposed to this, N2134 says in 5.6/4:

"If both operands are nonnegative then the remainder is nonnegative;
if not, the sign of the remainder is implementation-defined78)"

with footnote 78:

"According to work underway toward the revision of ISO C, the
preferred
algorithm for integer division follows the rules defined in the ISO
Fortran
standard, ISO/IEC 1539:1991, in which the quotient is always rounded
toward zero."

So viewing from the Status Quo I interpret that our C++ Standard does
currently would allow any rounding strategy (including truncation
"towards -inf") if one of the operands is negative.

I cannot say, whether the current state of affairs are by design or
not,
but the synchronization seems to be useful for most programmers.

Greetings from Bremen,

Daniel



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



