I am trying to get a valid response for
Math.round(Double.valueOf(1) / Double.valueOf(0))
but I am getting a random number as output. Can someone please help.
It's behaving exactly as documented - you're not getting "a random number", you're getting Long.MAX_VALUE
:
If the argument is positive infinity or any value greater than or equal to the value of
Long.MAX_VALUE
, the result is equal to the value ofLong.MAX_VALUE
.
In your case, the argument is positive infinity. Hence the result.
See more on this question at Stackoverflow