incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Far...@kyiv.vdiweb.com>
Subject RE: [PATCH] bitset.cc (STDCXX-297)
Date Tue, 10 Oct 2006 14:59:41 GMT
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Monday, October 09, 2006 10:55 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] bitset.cc (STDCXX-297)
> 
> > the bitset). Also, I think the code could be simplified as
> > follows:
> > 
> >   nbytes =   (((maxbits | (sizeof *bits * CHAR_BIT - 1)) >> 5)
> >            + (0 != (maxbits & (sizeof *bits * CHAR_BIT - 1)))) << 2;
> 
> With the magic 5 and 2 replaced by expressions parametrized 
> on sizeof *bits, of course.
  How log2 can be calculated at compile time?

  5 is log2(sizeof (*bits) * CHAR_BIT)
  2 is log2(sizeof (*bits))

Farid.

Mime
View raw message