ersocon

Float and Double look very similar. But how to decide which one of them to use in Haskell? Is there a difference in performance? Let's examine this questions a bit closer in this article.

First, we need to understand the difference of **Float** and **Double**:

I used to forget the definition of both types, mix them and didn't really knew when to choose one of them. Since Haskell is a strongly typed language, I was finally forced to understand and remember those types (and I assume you came here for the same reason :) ).

Float is a type used to represent floating point numbers. The important part here: It's single precision. With this definition it's easy to derive the name **Double**. It is used to represent floating point numbers as well, but with *double* precision. Float is in a way the small brother of Double. This is the way I remember the two of them.

Now, which one should I use in my program when writing Haskell applications? Haskell usually uses a 64 bits wide systems native floating-point representation when it sees a **Double** type. Because of Doubles higher precision compiler writers concentrate more on Doubles efficiency. Having this in mind, it's good practice to use Double in favor of Float.

© Copyright 2022 - Ersocon - All rights reservedVer. 2.3.0.7