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; }