This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3] FP printing, take 2
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: Gawain Bolton <gp dot bolton at computer dot org>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Wed, 01 Sep 2004 09:33:28 -0400
- Subject: Re: [v3] FP printing, take 2
- References: <16691.54895.612575.291103@localhost.localdomain><4134DB04.4000809@computer.org>
Gawain Bolton writes:
> Hi Jerry,
>
> Yes I have one comment... Maybe question actually because I must
> admit, I don't know the first thing about the locale part of
> libstdc++! The following lines strike me as odd:
>
> *__sbuf++ = __digits[*__buf++ - '0'];
>
> *__tb-- = '0' + (__decp % 10);
>
> Here the implicit assumption seems to be that the character set used
> orders the digits in successive increasing order from '0' to '9', which
> is true of ASCII.
>
> Is this a valid assumption for the locale library?
I have to admit I'm not sure about whether digit chars are required to be in
order. However, the spec does say that the numbers are to be rendered in the
C locale, then widened to the final locale. So we can use ascii digit chars
here.
I suspect a lot of code would break if you couldn't assume that 0-9 were
contigous. IIRC, even EBCDIC has continuous digit chars.
Jerry