diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-09-01 17:05:20 +0200 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-09-02 10:16:36 +0100 |
commit | dcac166e4a6af00ae18852a1cca002ae0b5dd818 (patch) | |
tree | cb414c380d2ed5823c14e9bb4a9d6059a32120c8 /source/fitz/printf.c | |
parent | 84c616094639d38d076aba71bf8283b532f434f6 (diff) | |
download | mupdf-dcac166e4a6af00ae18852a1cca002ae0b5dd818.tar.xz |
Add locale-independent number formatting and parsing functions.
Diffstat (limited to 'source/fitz/printf.c')
-rw-r--r-- | source/fitz/printf.c | 38 |
1 files changed, 0 insertions, 38 deletions
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 @@ -15,44 +15,6 @@ static void fmtputc(struct fmtbuf *out, int c) } /* - * 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. */ |