void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONG_DOUBLE __x) { #ifdef USE_SPRINTF_INSTEAD char cvtbuf[128]; # ifndef _STLP_NO_LONG_DOUBLE # ifndef N_PLAT_NLM snprintf(ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56! # else sprintf(cvtbuf, "%Lf", __x); // check for 1234.56! # endif # else snprintf(ARRAY_AND_SIZE(cvtbuf), "%f", __x); // check for 1234.56! # endif char *p = strchr( cvtbuf, '.' ); if ( p == 0 ) { out.append( cvtbuf ); } else { out.append( cvtbuf, p ); } #else char cvtbuf[NDIG+2]; char * bp; int decpt, sign; #ifndef _STLP_NO_LONG_DOUBLE bp = _Stl_qfcvtR(__x, 0, &decpt, &sign, cvtbuf); #else bp = _Stl_fcvtR(__x, 0, &decpt, &sign, cvtbuf); #endif if (sign) { out += '-'; } out.append(bp, bp + decpt); #endif // USE_PRINTF_INSTEAD }
size_t __format_float_fixed(__iostring &buf, const char * bp, int decpt, int sign, bool /* x */, ios_base::fmtflags flags, int precision, bool islong ) { size_t __group_pos; char static_buf[128]; int const BUF_SIZE = sizeof(static_buf) - 1; char *sbuf = static_buf; if (sign && decpt > -precision && *bp != 0) *sbuf++ = '-'; else if (flags & ios_base::showpos) *sbuf++ = '+'; int rzero = 0; int nn = decpt; int k = 0; int maxfsig = islong ? 2*MAXFSIG : MAXFSIG; do { int nnn = (min) (nn, BUF_SIZE); nn -= nnn; do { *sbuf++ = ((nnn <= 0 || *bp == 0 || k >= maxfsig) ? '0' : (++k, *bp++)); } while (--nnn > 0); buf.append(static_buf, sbuf); sbuf = static_buf; } while (nn != 0); // decimal point if needed __group_pos = buf.size() - 1; if (flags & ios_base::showpoint || precision > 0) { *sbuf++ = '.'; ++__group_pos; } // digits after decimal point if any nn = (min) (precision, MAXFCVT); if (precision > nn) rzero = precision - nn; while (nn != 0) { int nnn = (min) (nn, BUF_SIZE); nn -= nnn; while (--nnn >= 0) { *sbuf++ = (++decpt <= 0 || *bp == 0 || k >= maxfsig) ? '0' : (++k, *bp++); } buf.append(static_buf, sbuf); sbuf = static_buf; } // trailing zeros if needed while (rzero != 0) { int nnn = (min) (rzero, BUF_SIZE); rzero -= nnn; while (nnn-- > 0) { *sbuf++ = '0'; } buf.append(static_buf, sbuf); sbuf = static_buf; } return __group_pos; }