diff src/c/urweb.c @ 285:e89076c41c39

toString for float and bool
author Adam Chlipala <adamc@hcoop.net>
date Sun, 07 Sep 2008 10:20:42 -0400
parents 77a28e7430bf
children ffe5b01908ae
line wrap: on
line diff
--- a/src/c/urweb.c	Sun Sep 07 10:13:02 2008 -0400
+++ b/src/c/urweb.c	Sun Sep 07 10:20:42 2008 -0400
@@ -681,3 +681,21 @@
   ctx->heap_front += len+1;
   return r;
 }
+
+lw_Basis_string lw_Basis_floatToString(lw_context ctx, lw_Basis_float n) {
+  int len;
+  char *r;
+
+  lw_check_heap(ctx, FLOATS_MAX);
+  r = ctx->heap_front;
+  sprintf(r, "%g%n", n, &len);
+  ctx->heap_front += len+1;
+  return r;
+}
+
+lw_Basis_string lw_Basis_boolToString(lw_context ctx, lw_Basis_bool b) {
+  if (b == lw_Basis_False)
+    return "False";
+  else
+    return "True";
+}