Lines Matching refs:dec

199 mpd_qset_string(mpd_t *dec, const char *s, const mpd_context_t *ctx,
208 mpd_set_flags(dec, 0);
209 dec->len = 0;
210 dec->exp = 0;
217 mpd_set_negative(dec);
224 mpd_setspecial(dec, sign, MPD_NAN);
240 mpd_setspecial(dec, sign, MPD_SNAN);
257 mpd_setspecial(dec, sign, MPD_INF);
271 dec->exp = strtoexp(exp);
274 (dec->exp == MPD_SSIZE_MAX ||
275 dec->exp == MPD_SSIZE_MIN)))
288 if (dec->exp < MPD_SSIZE_MIN+(mpd_ssize_t)fracdigits) {
289 dec->exp = MPD_SSIZE_MIN;
292 dec->exp -= (mpd_ssize_t)fracdigits;
298 if (dec->exp > MPD_EXP_INF) {
299 dec->exp = MPD_EXP_INF;
301 if (dec->exp == MPD_SSIZE_MIN) {
302 dec->exp = MPD_SSIZE_MIN+1;
312 if (!mpd_qresize(dec, len, status)) {
313 mpd_seterror(dec, MPD_Malloc_error, status);
316 dec->len = len;
318 string_to_coeff(dec->data, coeff, dpoint, (int)r, len);
320 mpd_setdigits(dec);
321 mpd_qfinalize(dec, ctx, status);
326 mpd_seterror(dec, MPD_Conversion_syntax, status);
331 mpd_qset_string_exact(mpd_t *dec, const char *s, uint32_t *status)
336 mpd_qset_string(dec, s, &maxcontext, status);
340 mpd_seterror(dec, MPD_Invalid_operation, status);
396 /* Print the coefficient of dec to string s. len(dec) > 0. */
398 coeff_to_string(char *s, const mpd_t *dec)
404 x = mpd_msword(dec);
408 for (i=dec->len-2; i >= 0; --i) {
409 x = dec->data[i];
416 /* Print the coefficient of dec to string s. len(dec) > 0. dot is either
419 coeff_to_string_dot(char *s, char *dot, const mpd_t *dec)
425 x = mpd_msword(dec);
429 for (i=dec->len-2; i >= 0; --i) {
430 x = dec->data[i];
462 _mpd_to_string(char **result, const mpd_t *dec, int flags, mpd_ssize_t dplace)
468 if (mpd_isspecial(dec)) {
471 if (mpd_isnan(dec) && dec->len > 0) {
473 mem += dec->digits;
481 if (mpd_isnegative(dec)) {
491 if (mpd_isnan(dec)) {
492 if (mpd_isqnan(dec)) {
500 if (dec->len > 0) { /* diagnostic code */
501 cp = coeff_to_string(cp, dec);
504 else if (mpd_isinfinite(dec)) {
513 assert(dec->len > 0);
526 * 1) ldigits := dec->digits - dec->exp
539 ldigits = dec->digits + dec->exp;
544 else if (flags&MPD_FMT_FIXED || (dec->exp <= 0 && ldigits > -6)) {
551 if (mpd_iszero(dec)) {
555 dplace = -1 + mod_mpd_ssize_t(dec->exp+2, 3);
573 mem = -dplace + dec->digits + 2;
575 else if (dplace >= dec->digits) {
579 mem = dec->digits;
590 if (mpd_isnegative(dec)) {
601 /* space: -dplace+dec->digits+2 */
607 cp = coeff_to_string(cp, dec);
609 else if (dplace >= dec->digits) {
611 cp = coeff_to_string(cp, dec);
612 for (k = 0; k < dplace-dec->digits; k++) {
617 /* space: dec->digits+1 */
618 cp = coeff_to_string_dot(cp, cp+dplace, dec);
648 mpd_to_sci(const mpd_t *dec, int fmt)
654 (void)_mpd_to_string(&res, dec, flags, MPD_DEFAULT_DOTPLACE);
659 mpd_to_eng(const mpd_t *dec, int fmt)
665 (void)_mpd_to_string(&res, dec, flags, MPD_DEFAULT_DOTPLACE);
670 mpd_to_sci_size(char **res, const mpd_t *dec, int fmt)
675 return _mpd_to_string(res, dec, flags, MPD_DEFAULT_DOTPLACE);
679 mpd_to_eng_size(char **res, const mpd_t *dec, int fmt)
684 return _mpd_to_string(res, dec, flags, MPD_DEFAULT_DOTPLACE);
1248 mpd_qformat_spec(const mpd_t *dec, const mpd_spec_t *spec,
1276 if (mpd_isspecial(dec)) {
1297 if (!mpd_qcopy(&tmp, dec, status)) {
1301 dec = &tmp;
1316 if (dec->digits > prec) {
1317 _mpd_round(&tmp, dec, prec, ctx,
1319 dec = &tmp;
1323 if (mpd_iszero(dec)) {
1327 _mpd_round(&tmp, dec, spec->prec+1, ctx,
1329 dec = &tmp;
1333 mpd_qrescale(&tmp, dec, -spec->prec, ctx,
1335 dec = &tmp;
1341 if (mpd_iszero(dec) && dec->exp > 0) {
1342 mpd_qrescale(&tmp, dec, 0, ctx, &workstatus);
1343 dec = &tmp;
1365 result.nbytes = _mpd_to_string(&result.data, dec, flags, dplace);
1372 if (*spec->dot != '\0' && !mpd_isspecial(dec)) {
1401 mpd_qformat(const mpd_t *dec, const char *fmt, const mpd_context_t *ctx,
1411 return mpd_qformat_spec(dec, &spec, ctx, status);
1571 mpd_fprint(FILE *file, const mpd_t *dec)
1575 decstring = mpd_to_sci(dec, 1);
1586 mpd_print(const mpd_t *dec)
1590 decstring = mpd_to_sci(dec, 1);