byte + byte = int: why?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 18 19:04:43 UTC 2019


On Fri, Jan 18, 2019 at 01:49:23PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 1/18/19 12:26 PM, Mek101 wrote:
[...]
> > Then why isn't int + int = long? If i did the example above, they
> > wouldn't fit in a int for sure, yet the result is of the same type.
> > Why should byte be any different?
> 
> There are other inconsistencies too, like += (which works on byte +=
> byte).
> 
> As others have said, those are the rules D has for historical reasons,
> you just have to deal with them.
[...]

Or use my nopromote module. ;-)  </shameless self-promotion>


T

-- 
Nearly all men can stand adversity, but if you want to test a man's character, give him power. -- Abraham Lincoln


More information about the Digitalmars-d-learn mailing list