Bounded and floating types

Stefan O'Rear stefanor at cox.net
Mon Dec 3 22:18:42 EST 2007


On Tue, Dec 04, 2007 at 02:21:11AM -0000, kahl at cas.mcmaster.ca wrote:
> Conal Elliott wrote:
> 
>  > Pure values have
>  > time minBound, while eternally unknowable values (non-occurring events) have
>  > time maxBound.  Hm.  Now that I put it that way, I realize that I don't want
>  > to use existing minBound and maxBound if they're finite.  (My event types
>  > are temporally polymorphic.)  I'm mainly interested in Float/Double times,
>  > which have infinities in practice but apparently not guaranteed by the
>  > language standard.
> 
> And even in the current implementation with infinities,
> maxBound would be NaN, not +Inf:
> 
> Prelude> let z = 0 :: Double
> Prelude> 0 / z
> NaN
> Prelude> 1 / z
> Infinity
> Prelude> (-1) / z
> -Infinity
> Prelude> (0 / z) `compare` (1 / z)
> GT
> Prelude> (0 / z) `compare` ((-1) / z)
> GT
> 
> This is another case where the linear ordering provided by Ord
> has an arbitrary flavour, since the type of IEEE doubles
> does not have a ``natural'' linear ordering.
> (And I consider this as independent of
>  whether the IEEE standard prescribes this ordering or not.)

It's rather worse than that.

Prelude> let nan = 0/0
Prelude> nan > nan
False
Prelude> nan < nan
False
Prelude> nan == nan
False

Double isn't even totally ordered!

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/libraries/attachments/20071203/b84de8de/attachment.bin


More information about the Libraries mailing list