This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] FP printing, take 2


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


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