Re: Should negating an unsigned integral be an error?

2018-01-30 Thread Michael via Digitalmars-d
On Tuesday, 30 January 2018 at 14:08:41 UTC, bauss wrote: On Tuesday, 30 January 2018 at 11:09:08 UTC, Michael wrote: On Monday, 29 January 2018 at 10:06:41 UTC, Jonathan M Davis wrote: On Monday, January 29, 2018 09:58:00 Dave Jones via Digitalmars-d wrote: Given uint i = 12345; should

Re: Should negating an unsigned integral be an error?

2018-01-30 Thread bauss via Digitalmars-d
On Tuesday, 30 January 2018 at 11:09:08 UTC, Michael wrote: On Monday, 29 January 2018 at 10:06:41 UTC, Jonathan M Davis wrote: On Monday, January 29, 2018 09:58:00 Dave Jones via Digitalmars-d wrote: Given uint i = 12345; should writeln(-i) be an error? or maybe i should be automatically

Re: Should negating an unsigned integral be an error?

2018-01-30 Thread Michael via Digitalmars-d
On Monday, 29 January 2018 at 10:06:41 UTC, Jonathan M Davis wrote: On Monday, January 29, 2018 09:58:00 Dave Jones via Digitalmars-d wrote: Given uint i = 12345; should writeln(-i) be an error? or maybe i should be automatically cast to a larger signed type? It arguably should be, but

Re: Should negating an unsigned integral be an error?

2018-01-29 Thread Jonathan M Davis via Digitalmars-d
On Monday, January 29, 2018 09:58:00 Dave Jones via Digitalmars-d wrote: > Given > > uint i = 12345; > > should > > writeln(-i) > > be an error? or maybe i should be automatically cast to a larger > signed type? It arguably should be, but it's pretty common in C/C++ to get uint.max with -1, and I

Should negating an unsigned integral be an error?

2018-01-29 Thread Dave Jones via Digitalmars-d
Given uint i = 12345; should writeln(-i) be an error? or maybe i should be automatically cast to a larger signed type?