[v3] Print ints directly to streambuf

Richard Henderson rth@redhat.com
Tue Feb 25 21:52:00 GMT 2003


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~



More information about the Libstdc++ mailing list