#include "mupdf/fitz.h"12/*3* compute decimal integer m, exp such that:4* f = m*10^exp5* m is as short as possible with losing exactness6* assumes special cases (NaN, +Inf, -Inf) have been handled.7*/8void9fz_ftoa(float f, char *s, int *exp, int *neg, int *ns)10{11char buf[40], *p = buf;12int i;1314for (i = 0; i < 10; ++i)15{16sprintf(buf, "%.*e", i, f);17if (fz_atof(buf) == f)18break;19}2021if (*p == '-')22{23*neg = 1;24++p;25}26else27*neg = 0;2829*ns = 0;30while (*p && *p != 'e')31{32if (*p >= '0' && *p <= '9')33{34*ns += 1;35*s++ = *p;36}37++p;38}3940*exp = fz_atoi(p+1) - (*ns) + 1;41}424344