Re: mod of negative number

2024-09-24 Thread Timon Gehr via Digitalmars-d-learn
On 9/23/24 21:52, Craig Dillabaugh wrote: Why does the following program:     \     import std.stdio;     int main(string[] args) {     uint Q = 7681;     writeln("Val = ", -1 % Q);     return 0;     }     \     Print     Val = 5568 Was hopin

Re: mod of negative number

2024-09-24 Thread Sergey via Digitalmars-d-learn
On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: \ import std.stdio; int main(string[] args) { uint Q = 7681; writeln("Val = ", -1 % Q); return 0; } \ Print Val

Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 20:02:25 UTC, Craig Dillabaugh wrote: On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: snip Opps, sorry. I was expecting 7680 (not -1 or 5568). After a bit of research I see this is the same behavior as C,

Re: mod of negative number

2024-09-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 23, 2024 1:52:02 PM MDT Craig Dillabaugh via Digitalmars- d-learn wrote: > Why does the following program: > > \ > import std.stdio; > > int main(string[] args) { > uint Q = 7681; > writeln("Val = ", -1 % Q); > retur

Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: \ import std.stdio; int main(string[] args) { uint Q = 7681; writeln("Val = ", -1 % Q); return 0; } \ Print Val