From dcac166e4a6af00ae18852a1cca002ae0b5dd818 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 1 Sep 2014 17:05:20 +0200 Subject: Add locale-independent number formatting and parsing functions. --- source/fitz/printf.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'source/fitz/printf.c') diff --git a/source/fitz/printf.c b/source/fitz/printf.c index e9d43dbb..b4fe844a 100644 --- a/source/fitz/printf.c +++ b/source/fitz/printf.c @@ -14,44 +14,6 @@ static void fmtputc(struct fmtbuf *out, int c) ++(out->n); } -/* - * Compute decimal integer m, exp such that: - * f = m*10^exp - * m is as short as possible with losing exactness - * assumes special cases (NaN, +Inf, -Inf) have been handled. - */ -static void fz_dtoa(float f, char *digits, int *exp, int *neg, int *ndigits) -{ - char buf[20], *s, *p, *e; - int n; - - /* TODO: binary search */ - for (n = 1; n < 9; ++n) { - sprintf(buf, "%+.*e", n, f); - if (strtof(buf, NULL) == f) - break; - } - - *neg = (buf[0] == '-'); - - p = buf + 3; - e = strchr(p, 'e'); - *exp = atoi(e + 1) - (e - p); - - if (e[-1] == '0') { - --e; - ++(*exp); - } - - s = digits; - *s++ = buf[1]; - while (p < e) - *s++ = *p++; - *s = 0; - - *ndigits = s - digits; -} - /* * Convert float to shortest possible string that won't lose precision, except: * NaN to 0, +Inf to FLT_MAX, -Inf to -FLT_MAX. -- cgit v1.2.3