Computes 2 x exactly be exploiting the IEEE format @param x the integer power to raise 2 too @return 2 x
(int x)
| 115 | * @return 2<sup>x</sup> |
| 116 | */ |
| 117 | public static double pow2(int x) |
| 118 | { |
| 119 | if(x > Double.MAX_EXPONENT) |
| 120 | return Double.POSITIVE_INFINITY; |
| 121 | if(x < Double.MIN_EXPONENT) |
| 122 | return 0; |
| 123 | return longBitsToDouble((x+1023L)<<52); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Computes 2<sup>x</sup>.<br> |
no outgoing calls