If I asked you what the largest possible
Integer in Java is, you would easily answer 2^31-1, or
Integer.MAX_VALUE. Smallest possible
How about a
Long? It’s also a
Number, and each
MAX_VALUE, and you would be right to refer to them.
Obvious and boring, right?
How about a
It’s also a
Number, and so it has
Double.MAX_VALUE, and yes that is the maximum. Minimum? Let me go already, obviously
I only learned it today even though I’ve been programming Java for years.
Double.MIN_VALUE is actually a positive number. Quick look at docs says it all: It is the smallest positive nonzero value of type double. If you’re really looking for the smallest value of
Double, you need to refer to
Yes, docs are very clear about it. Yes, it is a static constant, so LSP does not really apply (as if Java didn’t violate it all the time). Yet I still think it looks like a duck, it quacks like a duck, but needs batteries. It has different semantics for no good reason, does not follow the principle of least surprise and is plain unintuitive. I add it to my shelf of quirks along with half of Swing, everything around
equals and… what am I still doing here by the way?