mod of negative number
Craig Dillabaugh
craig.dillabaugh at gmail.com
Mon Sep 23 19:52:02 UTC 2024
Why does the following program:
\<code>
import std.stdio;
int main(string[] args) {
uint Q = 7681;
writeln("Val = ", -1 % Q);
return 0;
}
\</code>
Print
Val = 5568
Was hoping for 1.
I assume it is an integer promotion issue, but I am unsure how to
resolve. I tried replacing the Q with to!int(Q) but this gave me
-1, which is closer but not right either.
More information about the Digitalmars-d-learn
mailing list