From -684625109898563525
X-Google-Thread: f78e5,c063db358aabf0d8
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 19 Feb 2007 08:50:01 -0600
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
From: "James Kanze" <james.kanze@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: Integer division specification
Organization: http://groups.google.com
Message-ID: <1171875476.464948.69200@v45g2000cwv.googlegroups.com>
References: <n5u5t219ouhheqn399kchuhhrd3jm7er69@4ax.com>
   <k9odt25148b6olt421jip03kqqbcq4meo1@4ax.com>
   <45d8adcb$0$7365$19deed1b@news.inter.NL.net>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.1) Gecko/20061208 Firefox/2.0.0.1,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: v45g2000cwv.googlegroups.com; posting-host=62.160.54.162;
   posting-account=uN4QgA0AAAC_qk3WofNKjyjXNSBMXL2b
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id l1J8wBew027001
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Date: Mon, 19 Feb 2007 08:49:15 CST
Lines: 65
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-YpM71KgOCxHwAv5AApXzHUATWj7jf5f2zY6YhMXXpaoFR8so0m9CAFc/iBzxiM7GqT23H/eB5UTDsEJ!INlRfojIQZKApmptsOZzAm74cDct9DGNF4cVnOpw4bMMniYOoEBRUHeEn+hXdCAI4iKlqi7CP7BN!asK4hz2DeSuuLbd9TFqeE/QQbaxi6Wfh9WyNf0mFFg==
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news2.google.com comp.std.c++:5629

Maarten Kronenburg wrote:
> "Gennaro Prota"  wrote
> > >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
> > :-)).

> Of course also I don't know the answer of this, because somewhere in the
> world there may be hardware with a compiler where truncation is not towards
> zero.

I doubt it.  Fortran requires truncation toward zero, and when
the C committee considered the issue, they were unable to find
such hardware.

> All I know is that at least on x86 the truncation is toward zero. When
> the truncation is toward -inf, then technically the remainder becomes the
> modulo.
> In document N2134, 5.6 [expr.mul], it says "the sign of remainder is
> implementation defined" with footnote 78: "According to work underway ...
> the quotient is always rounded toward zero."
> The problem of course is how to know if there are compilers with hardware
> not truncating toward zero. So the solution may then be to have a list of
> e-mail addresses of compiler vendors who can answer that question for you,
> then you could check all the compiler vendors and ask them personally. When
> they wouldn't respond then at least they had the opportunity to object.

You can probably suppose that any vendor supporting both C and
C++ will handle division the same way in both languages, and C
requires truncation to zero, so the only vendors you'd really
have ask are those who only support C++, and not C.  And I don't
think that there are too many of those.

At the hardware level, of course, hardware tends to be designed
to make programs run faster.  Since most (all?) major languages
except C++ require truncation to zero, it seems a safe bet that
all hardware truncates to zero.

I suspect that the original decision to truncate to zero in
Fortran was based in fact on what the hardware at the time did.
And that the hardware at that time did whatever was simplest and
fastest.  Which makes me think that there probably isn't any
reason for hardware ever to do anything else.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


---
[ 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                      ]



