New integer promotion rules
Basile B.
b2.temp at gmx.com
Wed Jan 17 20:45:56 UTC 2018
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
> And here is why is bothering me:
>
> auto max = isNegative ? cast(Unsigned!T)(-T.min) :
> cast(Unsigned!T)T.max);
>
> The generic code above (which worked for all signed integral
> types T in 2.077) must be rewritten like this in 2.078:
>
> static if (T.sizeof >= 4)
> auto max = isNegative ? cast(Unsigned!T)(-T.min) :
> cast(Unsigned!T)T.max;
> else
> auto max = isNegative ? cast(Unsigned!T)(-cast(int)T.min) :
> cast(Unsigned!T)T.max;
>
> Now I have to translate an 1-liner in a 4-liner all around my
> project.
Yes i know. In a way i agree but in another i've accepted the
thing, that's why for example there's:
https://github.com/dlang/phobos/pull/5958/files
I had to do similar things in my own stuff.
Other people had to as well.
In my stuff i've used
`cast(ubyte) (stuff * -1)`
instead of
`-stuff`
because i've verified that in both cases an asm NEG is generated.
But well, i understand your concern ;)
More information about the Digitalmars-d-learn
mailing list