aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index bb9019e..ed31acb 100644
--- a/misc.c
+++ b/misc.c
@@ -402,6 +402,12 @@ void copy_left_justified(char *buf, size_t sz, const char *str)
buf[sz - 1] = 0;
}
+/* another kludge for platforms without %g support in *printf() */
+int ftoa(char *buf, float f)
+{
+ return sprintf(buf, "%d.%06d", (int)f, abs((int)((f - (int)f)*1e6)));
+}
+
/* Returns a dynamically allocated label for a generic button.
* Game-specific buttons should go into the `label' field of key_label
* instead. */