Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 516

Answer by Federico klez Culloca for Why does misusing 1 instead of 1.0 from an int exceeding limits effect the value we get when we convert it to a double

$
0
0

In the first case a + a overflows to Integer.MIN_VALUE, then you switch to a double context with -1.0 which gives a negative number (Integer.MIN_VALUE - 1), since a double can hold a number smaller than Integer.MIN_VALUE.

In the second example you stay in an int context, which means that a + a overflows to Integer.MIN_VALUE, then subtracting 1 from that underflows and takes you back to Integer.MAX_VALUE.


Viewing all articles
Browse latest Browse all 516

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>