Infinity numbers are numbers larger than Double.MAX_VALUE or smaller than -Double.MAX_VALUE. 1.0/0.0 is infinite. So is 2*Double.MAX_VALUE.
Math.pow(Double.MAX_VALUE,2)
is obviously larger than Double.MAX_VALUE
. Squaring of a largest possible number will result into something that regular number system can't represent.
Math.sqrt(Math.pow(this.re, 2) + Math.pow(this.im, 2))
==> Math.sqrt(Math.pow(Double.MAX_VALUE, 2) + Math.pow(Double.MAX_VALUE, 2))
==> Math.sqrt(Infinity + Infinity)
==> Infinity
Before the sqrt can be calculated, the squaring of a double max value resulted into infinity. you can't find sqrt of an Infinity number, so what you got it perfectly valid.