Sajal Saxena
Sajal Saxena

Reputation: 221

Range Check for Double datatype variable

I am converting a string to double value using Double.parseDouble. I want to put a range check on double value to check if it lies in by default range of double data type. Please suggest how can i make a range check for double variable.

Thanks.

Upvotes: 0

Views: 670

Answers (1)

Patricia Shanahan
Patricia Shanahan

Reputation: 26185

Technically, the range of double is Double.NEGATIVE_INFINITY through Double.POSITIVE_INFINITY, and no real number is outside that range. If you want to eliminate the overflow to infinity cases, test Double.isFinite(val) after the conversion.

Upvotes: 1

Related Questions