From 3c58fa90c8fd063c7ccb00a85a7e238ae2788a73 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 19 Jan 2014 16:20:59 +0100 Subject: [PATCH] Fix bug in toFixed, toPrecision and toExponential. --- jsbnumber.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jsbnumber.c b/jsbnumber.c index d69d310..57afaa8 100644 --- a/jsbnumber.c +++ b/jsbnumber.c @@ -37,7 +37,7 @@ static int Np_toFixed(js_State *J, int n) js_Object *self = js_toobject(J, 0); int width = js_tonumber(J, 1); if (self->type != JS_CNUMBER) jsR_error(J, "TypeError"); - sprintf(buf, "%*f", width, self->u.number); + sprintf(buf, "%.*f", width, self->u.number); js_pushstring(J, buf); return 1; } @@ -48,7 +48,7 @@ static int Np_toExponential(js_State *J, int n) js_Object *self = js_toobject(J, 0); int width = js_tonumber(J, 1); if (self->type != JS_CNUMBER) jsR_error(J, "TypeError"); - sprintf(buf, "%*e", width, self->u.number); + sprintf(buf, "%.*e", width, self->u.number); js_pushstring(J, buf); return 1; } @@ -59,7 +59,7 @@ static int Np_toPrecision(js_State *J, int n) js_Object *self = js_toobject(J, 0); int width = js_tonumber(J, 1); if (self->type != JS_CNUMBER) jsR_error(J, "TypeError"); - sprintf(buf, "%*g", width, self->u.number); + sprintf(buf, "%.*g", width, self->u.number); js_pushstring(J, buf); return 1; }