I am writing algorithms inside methods that return BigDecimal values but now and again the result calculated will be + or - infinity.
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.
eg Double.POSITIVE_INFINITY;
So how do I store infinity in a BigDecimal? Or is there another way of doing this?
public static BigDecimal myalgorithm(){
//code to store infinity in a BigDecimal
//return the BigDecimal holding infinity
}