On Thursday, 18 January 2018 at 17:54:59 UTC, rumbu wrote:
On Thursday, 18 January 2018 at 12:51:48 UTC, Dominikus Dittes
target = isNegative ? cast(Unsigned!T)(-c) : cast(Unsigned!T)c;
That would have been better even before the change, because
the operator '-' used on unsigned types is likely to produce
unexpected results, if the behaviour is defined at all.
I don't think so:
ulong c = 128;
bool isNegative = true;
byte target = isNegative ? -cast(ubyte)c : cast(ubyte)c;
Error Deprecation: integral promotion not done for
`-cast(ubyte)c`, use '-transition=intpromote' switch or
`-cast(int)(cast(ubyte)c)`
My bad, it works. Thanks:
ulong c = 128;
bool isNegative = true;
byte target = isNegative ? cast(ubyte)-c : cast(ubyte)c;