[Haskell-cafe] Why aren't Float and Double Bounded?

Josh Lee jleedev at gmail.com
Tue Nov 27 15:16:08 EST 2007


On Tue, 27 Nov 2007 14:41:59 -0500
Isaac Dupree <isaacdupree at charter.net> wrote:

> Henning Thielemann wrote:
> > On Mon, 26 Nov 2007, Jason Dusek wrote:
> > 
> >> Among numeric types, it seems that only integer types are Bounded.
> > 
> > Maybe because IEEE format supports Infinity?
> 
> therefore, maxBound is Infinity and minBound negative infinity?

Using Infinity would go against the meaning of Enum. In the
Double/Float types, succ and pred mean "add/subtract 1.0", as opposed
to the unit of least precision. In fact, succ and pred lose meaning
once the precision of the floats exceeds a certain value.

> until (\x -> x == succ x) succ 1.0 :: Float
1.6777216e7

It would be interesting to have an enumeration for Double/Float that
goes from -Infinity to Infinity, reaching every single number on the
way.

Josh Lee


More information about the Haskell-Cafe mailing list