float has a use after all.

After many years believing there was no good use for float, I discover its never too late to eat my words. float has significant round errors and doesn't save much memory compared with double.

However I have situation where I want small whole numbers (no rounding error) and I want to handle not-a-number transparently. I also want to minimise data passed between threads to cut latency. So floatturns out to be the best solution. :-P

Comments

  1. I first got surprise by your word that "float has no use" , indeed the point you mentioned is valid and floating point arithmetic vary between JVM to JVM but you can't get away without floating point calculation in many places.

    Thanks
    Javin
    How classpath works in Java

    ReplyDelete
  2. It is common to assume if you want floating point, this means float, esp if you use SQL where float is 64-bit. However in Java if you want floating point, you should use double 99% of the time.

    ReplyDelete

Post a Comment

Popular posts from this blog

Java is Very Fast, If You Don’t Create Many Objects

System wide unique nanosecond timestamps

What does Chronicle Software do?