[Haskell-cafe] bitSize

Maciej Marcin Piechotka uzytkownik2 at gmail.com
Mon Aug 29 12:32:51 CEST 2011


On Fri, 2011-08-26 at 20:30 +0100, Andrew Coppin wrote:
> 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)...

According to random side (http://gruntthepeon.free.fr/ssemath/) not so
new computers can compute 15.5 milions of serial logarithms per second
(62 millions in total). I'd say that overhead of Integer might be much
bigger then cost of logarithm.

Best regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110829/a15c98b8/attachment.pgp>


More information about the Haskell-Cafe mailing list