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.
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.
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.
Fixed dmd 1.047 and 2.032
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル