Oh Dear
Michiel Helvensteijn
m.helvensteijn.remove at gmail.com
Sun Jul 12 14:16:18 PDT 2009
Michiel Helvensteijn wrote:
> Walter, surely this test shouldn't take more than a minute for you (or
> anyone else with a D compiler installed).
Ok, ok. I'll do it. Here's the results:
----------------------------------
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. I've updated issue 3165 with
this information.
Hope that helps.
--
Michiel Helvensteijn
More information about the Digitalmars-d
mailing list