[Haskell] instance Bounded Double

John Meacham john at repetae.net
Sun Mar 13 23:08:56 EST 2005


On Sun, Mar 13, 2005 at 11:08:26PM +0000, Thomas Davie wrote:
> I may be barking up the wrong tree here, but I think the key to this 
> discussion is that real numbers are not bounded, while doubles are 
> bounded.  One cannot say what the smallest or largest real number are, 
> but one can say what the smallest or largest double are (and it is 
> unfortunately implementation specific, and probably pretty messy to set 
> up).  We could define maxBound as 
> (2^(mantisa_space))^(2^(exponent_space)) and min bound pretty 
> similarly... But I'm sure that everyone will agree that this is a 
> horrible hack.

I don't see how this is any more hacky than defining the minBound for
int as - 2^(number of bits - 1 ) and the maxBound as 2^(number of bits -
1) - 1 which seems to be generally accepted. 


In any case, I am in favor of including the instance, perhaps in its own
module,  due to the fact that if two useful libraries end up having to
declare their own, said libraries cannot be used together. However, if
they both rely on the same external module, no problems will arise. That
and since the maxBound is machine dependent, it seems like it Should be
made available somewhere in the libraries since portable programs would
have no other way to figure this sort of thing out.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell mailing list