Why does the xor operator on two bytes produce an int?

Because the language spec says so. It gives no reason, but I suspect that these are the most likely intentions:

  • To have a small and simple set of rules to cover arithmetic operations involving all possible combinations of types
  • To allow an efficient implementation – 32 bit integers are what CPUs use internally, and everything else requires conversions, explicit or implicit.

Leave a Comment