From 5424020296289544049
X-Google-Thread: f78e5,c063db358aabf0d8
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news4.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "Satish" <satishsanthanam@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: Integer division specification
Date: Wed, 21 Feb 2007 20:45:51 CST
Organization: http://groups.google.com
Lines: 74
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1172099129.686532.47280@j27g2000cwj.googlegroups.com>
References: <n5u5t219ouhheqn399kchuhhrd3jm7er69@4ax.com>
   <k9odt25148b6olt421jip03kqqbcq4meo1@4ax.com>
   <45d8adcb$0$7365$19deed1b@news.inter.NL.net>
   <1171875476.464948.69200@v45g2000cwv.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1172099136 7572 127.0.0.1 (21 Feb 2007 23:05:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 21 Feb 2007 23:05:36 +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/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.0 defrqcpc13dbkf6 (NetCache NetApp/6.0.4)
Complaints-To: groups-abuse@google.com
Injection-Info: j27g2000cwj.googlegroups.com; posting-host=129.35.231.16;
   posting-account=yNlyoQ0AAADLgrnzxV6Ac0DtmnxpN5aO
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id l1LN5f4P026794
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:5678

On Feb 19, 9:49 am, "James Kanze" <james.ka...@gmail.com> wrote:
> 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.ka...@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-...@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ:http://www.comeaucomputing.com/csc/faq.html                     ]

If using Intel, check if this document will be helpful.

ftp://download.intel.com/design/pentium/manuals/241430.htm



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



