[v3] FP printing, take 2

Jerry Quinn jlquinn@optonline.net
Wed Sep 1 13:41:00 GMT 2004


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



More information about the Gcc-patches mailing list