title: Getting Value of a Double Variable as Infinity
body: <p><strong>Code:</strong></p>
  
  <pre><code>var num = Math.pow(2.0, 5.0)
  num = Math.pow(5.0, num)
  num = Math.pow(2.0, num)
  print(num)
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Infinity
  </code></pre>
  
  <p>When I run the above code I am getting the value as Infinity. I can't understand what's happening. Is it crossing the limit of the <strong>double</strong> variable? Also, <code>Math.pow()</code> method will always return a <strong>double</strong>. </p>
  
  <p>I have to run the above code and need the value of <strong>num</strong> variable. How can I solve it?</p>
  
  <p>Actually, I have to compare two numbers after the calculation of exponential programmatically to determine which one is higher?</p>
  
  <p>Like: (2^(5^(2^5))) or (5^(2^(5^2))). So, which one is higher?</p>
  
  <p>Thanks in advance.</p>