Take the 2-minute tour ×  Scala has Double.isNaN for detecting
not-a-number but no Double.isInf for detecting (positive or
negative) infinity.  Why? I'd like to check whether a parameter
is a "real" number (i.e. has a numeric value). Converting it to
a string and checking for "inf" or something will do it, but
there must be a better way?  Like in C++:
http://en.cppreference.com/w/cpp/numeric/math/isinf  Using Scala
2.10  share|improve this question add comment  3 Answers  up
vote 9 down vote accepted  Scala's Double has an isInfinite
method, and Neg/Pos variants:  scala> val a = 22.0 a: Double =
22.0  scala> a.isInfinite res0: Boolean = false  scala> val b =
2.0/0 b: Double = Infinity  scala> b.isInfinite res1: Boolean =
true  scala> b.isPosInfinity res4: Boolean = true share|improve
this answer Thanks. Don't know how I missed it. –  akauppi Jun
17 '13 at 8:54 @akauppi Maybe because the REPL doesn't
autocomplete it. I see eclipse will offer it. –  som-snytt Jun
17 '13 at 16:23 @som-snytt oh, good point. IDEA