Java float vs. double and micro-optimization

Some people at work implemented a few classes all with floats and I am sick and tired of casting everything into float. There is absolutely no reason why floats should have ever been used. The original reason was because of memory and/or network and/or diskspace issues which is all now totally irrelevant because the project that these classes were mostly used for has now been scrapped. I recently ripped out a few classes from that project, however, because they are useful. I am finding them extremely annoying to use, however. Not only do they use floats but they are totally micro-optimized in other ways as well. I'm probably rewrite the class soon anyways so that it is readable. My opinion is that there is no reason to ever use anything other than ints, doubles, and bytes in Java. At leas in 2 years I have never come across any reason. Part of this is Java's fault for having two floating point types in the first place. I would have been much happier had this all been developed in Python.

Tags: 

Comments

Though quite old now, it was a pretty useless rant at the time and it still is now, if you ask me.

It comes down to "Don't use floats because I don't like them", which can hardly be considered a reasonable argument. Instead, if you want to try to confince people, mention what the difference between floats and doubles is, why floats where actually used in the past, why this is different now, why using floats is now a problem and why doubles would now be more appropiate. No concrete examples where given, just that some project used to have 'memory and/or network and/or diskspace issues' when not using floats. We don't know anything about that project.

Add new comment