title: How to store infinity in a BigDecimal (Java)?
body: <p>I am writing algorithms inside methods that return BigDecimal values but now and again the result calculated will be + or - infinity.<br>
  Rather than the program crashing I'd like to catch the exception and return infinity as a value like the way you could if the method was returning a double.</p>
  
  <p>eg Double.POSITIVE_INFINITY;</p>
  
  <p>So how do I store infinity in a BigDecimal? Or is there another way of doing this?</p>
  
  <pre><code>public static BigDecimal myalgorithm(){
  
  //code to store infinity in a BigDecimal
  //return the BigDecimal holding infinity 
  
  }
  </code></pre>