1
0
Fork 0
forked from len0rd/rockbox

puzzles: fix floating-point formatting

This is pretty ad-hoc, but the only other ways are to rewrite
sprintf (which would use too much memory on the c200v2), or
implement support for floats in rockbox's formatter, neither of
which are acceptable.

Change-Id: I70d59fd3e90a16e2db9ae0a84cd8c14807f50b46
This commit is contained in:
Franklin Wei 2017-08-16 11:35:32 -04:00
parent bf25f3e6e7
commit c78ff7f615
6 changed files with 23 additions and 7 deletions

View file

@ -23,6 +23,12 @@ int puts_wrapper(const char *s)
return 0;
}
int ftoa(char *buf, int len, float f)
{
/* biggest hack ever */
return rb->snprintf(buf, len, "%d.%06d", (int)f, (int)((f - (int)f)*1e6));
}
/* fixed-point wrappers */
static long lastphase = 0, lastsin = 0, lastcos = 0x7fffffff;