Reputation: 221
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
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