> In java if im adding a bunch of integer variables together...?

In java if im adding a bunch of integer variables together...?

Posted at: 2014-12-18 
Java has type promotion rules that work in a manner that prevents the loss of any data. Essentially, the most precise data type will be used in the end.

If you add an integer and a double, the result will be a double.

As Jeff said, yes, Java will promote everything to a double if any one expression is a double.

I am curious though: Why would you want to promote to double if all you are doing is addition? For division, the distinction is very important. But for addition, promoting integer to double would feel very wrong, unless the numbers are very very big, big enough to exceed the size of an integer. (Or, a long, since using longs would be the next best solution).

What is promotion to double giving you? Are the numbers really that big?