Subject: Re: [boost] [ICL] cardinality of float interval
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-02-17 13:30:13
John Reid wrote:
> cardinality( interval< float >( 1, 5 ) ) == 18446744073709551615
> Can this be true? Is this by design?
Clearly not true, since there are only 32 bits of unique float values possible and a fraction of those aren't normal. How many unique values of float are there between 1 and 5? Do you know how to calculate it? We would have to assume float conforms to the IEEE floating point standard (pretty safe) and then unpack the bits. What would you do with that information if you could get it?
I dimly recall that this issue came up during the review.
I think that the author may be viewing floating point as a continuous interval rather than discreet, so asking for the cardinality wouldn't make sense from that point of view. I think it would be nicer for cardinality to generate a syntax error than return a very large number when instantiated for a continuous interval type. I would use SFINAE protection on its regurn value. A STATIC_ASSERT would work too, but give much more verbose error messages.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk