Is there any reason why arithmetic operation on shorts and bytes	return int?
    d coder 
    dlang.coder at gmail.com
       
    Tue Dec 11 04:29:42 PST 2012
    
    
  
For some more clarity, when I compile the following code:
void main() {
  import std.stdio;
  byte a;
  byte b;
  byte c = a + b;
}
I get error:
test.d(6): Error: cannot implicitly convert expression (cast(int)a +
cast(int)b) of type int to byte
Why is D trying to convert bytes and shorts to integers before applying any
arithmetic operator?
Regards
- Puneet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121211/f743a9d0/attachment.html>
    
    
More information about the Digitalmars-d
mailing list