This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: V3 PATCH: numeric_limits<> support, fix PR/3865
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, Neil Booth <neil at daikokuya dot co dot uk>, Graham Stott <graham dot stott at btinternet dot com>, gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Sun, 01 Sep 2002 23:50:06 +0100
- Subject: Re: V3 PATCH: numeric_limits<> support, fix PR/3865
- Organization: Codesourcery LLC
- References: <20020829180944.GA7687@daikokuya.co.uk> <m365xtqyo0.fsf@soliton.integrable-solutions.net> <20020829192800.GA8493@daikokuya.co.uk> <m3k7m9pihv.fsf@soliton.integrable-solutions.net> <20020830094931.GD1063@redhat.com> <m3k7m8fwyc.fsf@soliton.integrable-solutions.net> <20020831015342.GG1501@redhat.com> <m3r8ge809j.fsf@soliton.integrable-solutions.net> <20020901212223.GA8139@redhat.com> <m3heh974pe.fsf@soliton.integrable-solutions.net> <20020901223108.GC8139@redhat.com>
Richard Henderson wrote:
> #define digits10_for_int_type(TYPE) \
> (sizeof (TYPE) * __CHAR_BIT__ == 8 ? 2 \
> : sizeof (TYPE) * __CHAR_BIT__ == 16 ? 4 \
> : sizeof (TYPE) * __CHAR_BIT__ == 32 ? 9 \
> : sizeof (TYPE) * __CHAR_BIT__ == 64 ? 18 + ((TYPE)-1 > 0) \
> : /* error */ 0)
>
> static const int digits10 = digits10_for_int_type (wchar_t);
surely something based on the following, culled from elsewhere
would be more concise?
// ln (2)/ln (10) * 2^12 == 1233.0188
#define DECIMALFORBITS(n) (((n) * 1233 + 4095) >> 12)
#define DECIMALINBITS(n) (((n) * 1233) >> 12)
leads to
#define digits10_for_int_type(TYPE) \
(((sizeof (TYPE) * __CHAR_BIT__ - ((TYPE)-1 < 0)) * 1233) >> 12)
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org