[Haskell-cafe] bitSize

Andrew Coppin andrewcoppin at btinternet.com
Fri Aug 26 21:30:02 CEST 2011


On 26/08/2011 07:36 PM, Steve Schafer wrote:
> On Fri, 26 Aug 2011 18:24:37 +0100, you wrote:
>
>> I would usually want #3 or #4.
>
> Out of curiosity, what for? While I do occasionally need to get a
> "logarithmic size estimate" of a number (which is basically what #3 and
> #4 are), the specific requirements in each case tend to vary, enough so
> that it's unlikely that a single function (other than simply taking the
> logarithm) can handle the majority of applications.

You wouldn't want to know how many bits you need to store on disk to 
reliably recreate the value? Or how many bits of randomness you need to 
compute a value less than or equal to this one?

I suppose I could use a binary logarithm. I'm just concerned that it 
would be rather slow. After all, I'm not interested in the exact 
logarithm (which is fractional), just the number of bits (which is a 
small integer)...



More information about the Haskell-Cafe mailing list