[Issue 3165] What kind of integer division does D use?

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3165

Andrei Alexandrescu  changed:

   What|Removed |Added

Version|unspecified |D2

--


[Issue 3165] What kind of integer division does D use?

2009-09-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3165


Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED




--- Comment #3 from Walter Bright   2009-09-03 
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: ---


[Issue 3165] What kind of integer division does D use?

2009-07-14 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3165


Stewart Gordon  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||s...@iname.com
 Blocks||677




--- Comment #2 from Stewart Gordon   2009-07-14 16:30:04 PDT ---
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: ---


[Issue 3165] What kind of integer division does D use?

2009-07-12 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3165





--- Comment #1 from Michiel Helvensteijn   2009-07-12 
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: ---