On Tue, 11 Jun 2013 12:12:25 +0200, Temtaime <temta...@gmail.com> wrote:
ubyte k = 10; ubyte c = k + 1;This code fails to compile because of: Error: cannot implicitly convert expression (cast(int)k + 1) of type int to ubyteWhy? It's pain in the ass, i think. My code contains only casts then.
Because it's unsafe. The compiler does not know if k+1 fits in a ubyte. (True, in this case it could know it, but it does not, and in the general case it can't know) -- Simen