math - Java arithmetic int vs. long -


I did a search on Google, but I think I can not find what I'm looking for. I'm trying to find some detailed information on how Arithmetic works in Java. For example, if you add two long joints, then is it using the same additional operator, which is used when adding two intits? Also, when you mix in long points and arithmetic arithmetic expressions, what is happening under the hood:

  long results; Long operating A = 1; Int opand B = 999999 999; Results = A + B;  

If someone can put some light on it or post links to related articles that would be awesome thank you!

EDIT: Thanks for the reply so far. Apart from this, is it safe to arithmetic with different antiquities, as long as you are specifying one of the broad primitive types in your expression?

When adding the type int int automatically widens for a long time and then the result As a result, two long additions are added

  • Byte to short, int, at, ati, ati,
  • integer, long, float or double
  • Long, float or double
  • long, long, float or double
  • long to float or double
  • Double to float

Comments