Well, it surprised me.
While Java's maximum and minimum values of Integers really do represent the highest and lowest int values, the same is not true of Doubles. Here, the maximum and minimum values represent the largest and smallest values of the magnitude of the numbers. That is, both values are positive even though Doubles are signed. The nomenclature is confusing but it makes sense (see here). Unlike Integers, Doubles are symmetric so the smallest number you can represent is -Double.MAX_VALUE.
Just when you get used to that, you find that Scala does it differently: Double.MinValue really is the smallest value a double can hold. That is,
Double.MinValue == -java.lang.Double.MAX_VALUE
It's debatable which is the most surprising.
No comments:
Post a Comment