The default floating point type in Java is the double. If you hard code a constant like 2.5
into your program, Java makes it a double automatically. When you do a
For metrics that don't need too many significant digits (such as screen offsets), it would be memory-inefficient to use double
s instead of float
s. Maximizing efficiency with regards to memory consumption is vitally important on mobile devices, where pretty much every resource is at a premium. And, when dealing with objects such as Rect
s—that could potentially be allocated by the thousands—it is clearly crucial to cut down on excess bits.
I'm sure there are other reasons too :-)