During Java Arithmetic operation , JVM do not throw Underflow or Overflow Exception. So many time we come across unexpected results and wondering what went wrong.
Wh
Java was based on C and C++ which is based on Assembly. In none of these languages is an exception thrown, partly because Exceptions were not in those languages when the arithmetic operations were designed.
It is much safer to use a larger type like long or double or BigInteger or BigDecimal in the first place and only use smaller types if you are really sure this is inappropriate.
It doesn't have to be a common problem if you use these wider types.