Bounded and floating types
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
> Prelude> 1 / z
> Prelude> (-1) / z
> Prelude> (0 / z) `compare` (1 / z)
> Prelude> (0 / z) `compare` ((-1) / z)
> 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
Prelude> nan < nan
Prelude> nan == nan
Double isn't even totally ordered!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/libraries/attachments/20071203/b84de8de/attachment.bin
More information about the Libraries