This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: V3 PATCH: numeric_limits<> support, fix PR/3865
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: Richard Henderson <rth at redhat dot com>, 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: Mon, 2 Sep 2002 00:22:35 +0100 (BST)
- Subject: Re: V3 PATCH: numeric_limits<> support, fix PR/3865
On Sun, 1 Sep 2002, Nathan Sidwell wrote:
> 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)
Since this is at compile-time, you don't need to save a division, so
surely you should be using an appropriate convergent to the continued
fraction instead. 59/196 is as good as the one you have (OK to 680 bits),
or 643/2136 is good up to 15436 bits.
--
Joseph S. Myers
jsm28@cam.ac.uk