shithub: libmujs

Download patch

ref: 05aeef461f7c52ff852cf84d81b1228ccdcb90d4
parent: dbeda99b66672d098c42f0d231a89a4288ad3a7d
author: Tor Andersson <tor.andersson@gmail.com>
date: Mon Apr 3 08:13:45 EDT 2017

Use regular number to string conversion in JSON.stringify.

JSON.stringify(0.1) should return "0.1" not "0.10000000000000001".

--- a/json.c
+++ b/json.c
@@ -108,8 +108,7 @@
 	else if (n == 0) js_puts(J, sb, "0");
 	else {
 		char buf[40];
-		sprintf(buf, "%.17g", n);
-		js_puts(J, sb, buf);
+		js_puts(J, sb, jsV_numbertostring(J, buf, n));
 	}
 }