digitalmars.D.bugs - [Issue 3165] New: What kind of integer division does D use?
- d-bugmail puremagic.com (26/26) Jul 12 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3165
- d-bugmail puremagic.com (33/33) Jul 12 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3165
- d-bugmail puremagic.com (21/21) Jul 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3165
- d-bugmail puremagic.com (12/12) Sep 03 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3165
http://d.puremagic.com/issues/show_bug.cgi?id=3165 Summary: What kind of integer division does D use? Product: D Version: unspecified Platform: All URL: http://www.digitalmars.com/d/2.0/expression.html#MulEx pression OS/Version: All Status: NEW Keywords: spec Severity: normal Priority: P2 Component: www.digitalmars.com AssignedTo: nobody puremagic.com ReportedBy: m.helvensteijn gmail.com Specify what kind of integer division D uses. The description is ambiguous when one or both operands of / are negative. So, in other words, what does D return from: 3 / 2 3 / -2 -3 / 2 -3 / -2 Such information should be part of the language specification. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 12 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3165 14:11:52 PDT --- I've ran the following test: ---------------------------------- import std.stdio; int main() { writefln(8/3); writefln(8/(-3)); writefln((-8)/3); writefln((-8)/(-3)); writefln(8%3); writefln(8%(-3)); writefln((-8)%3); writefln((-8)%(-3)); return 0; } ---------------------------------- outputs the following ---------- 2 -2 -2 2 2 2 -2 -2 ---------- So DMD uses truncated division. The quotient rounds towards zero and the remainder has the same sign as the dividend. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 12 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3165 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- URL|http://www.digitalmars.com/ |http://www.digitalmars.com/ |d/2.0/expression.html#MulEx |d/1.0/expression.html#MulEx |pression |pression CC| |smjg iname.com Blocks| |677 Changing URL since this is a D1 spec issue just the same. But you could well ask why it defines it as undefined for % but makes no comment at all (even on whether it's rounded up, down or off for +ve operands) for /. I've felt for ages that the programmer ought to have the choice between trunc and floor versions for both http://www.digitalmars.com/d/archives/digitalmars/D/13125.html but that's another matter. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3165 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 13:25:32 PDT --- Fixed dmd 1.047 and 2.032 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2009