it seems to be a silly question but I couldn't find the answer or at least I didn't know how to formulate it on Google.
When we add two bytes in Java, the result is an int.
But what about two long, or a long and an int ? Same questions for double and float. I'm a little bit lost between all those conversions.
A long. This is subject to §5.6.2 Binary Numeric Promotion, item 2:
double, the other is converted to double.float, the other is converted to float.long, the other is converted to long.int.You get an int when adding two bytes because of the last rule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With