This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] Print ints directly to streambuf


On Sat, Feb 22, 2003 at 12:35:08AM -0500, Jerry Quinn wrote:
> +    _M_estimate_length(_ValueT __v, const ios_base& __io, bool __neg) const
> +    {
> +      if (__builtin_expect((__io.flags() & ios_base::basefield) == ios_base::hex, false))
> +	{
> +	  size_t  __log16 = 1;
> +	  while ((__v >>= 4) != 0)
> +	    { ++__log16; }

  (sizeof(__v)*CHAR_BIT - __builtin_clz(__v) + 3) / 4

?  (Well, with __builtin_clz{,l,ll} chosen appropriately for the
type of __v.)  You'd also need an early-out check for a zero input.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]