On Wednesday, 17 September 2014 at 13:20:15 UTC, Shachar wrote:
On Wednesday, 17 September 2014 at 13:03:05 UTC, flamencofantasy wrote:
the result of ubyte + ubyte is int I believe.

Try;
void func( int c )
{
    ubyte a;

    a = cast(ubyte)(cast(ubyte)c + cast(ubyte)c);
}

From http://dlang.org/type, under Usual Arithmetic Conversions:
4. Else the integer promotions are done on each operand, followed by:
    1. If both are the same type, no more conversions are done.

So, as far as I can see, the specs disagree with you.

You missed that "integer promotions" are done first.

<http://dlang.org/type.html#Integer%20Promotions>:
Integer Promotions are conversions of the following types:
[...]
from    to
[...]
ubyte   int
[...]

So, integer promotions turn ubyte + ubyte into int + int.

Reply via email to