ushort arithmetic question

Jonathan Crapuchettes jcrapuchettes at gmail.com
Fri Oct 25 11:45:07 PDT 2013


Shouldn't this code work? Looking at the arithmetic conversions section 
of http://dlang.org/type.html, point 4.1 makes me think that I shouldn't 
be getting the error since they are the same type.

void main()
{
    ushort v1 = 1;
    ushort v2 = 1;
    ushort v3 = v1 + v2;
}

test.d(5): Error: cannot implicitly convert expression (cast(int)v1 + cast
(int)v2) of type int to ushort


More information about the Digitalmars-d-learn mailing list