Commit 9de9c353 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Fixed Number.toFixed for value 0 with 0 precision.

parent 59e339fa
......@@ -99,15 +99,17 @@ static inline jsstr_t *number_to_fixed(double val, int prec)
jsstr_t *ret;
WCHAR *str;
TRACE("%lf %d\n", val, prec);
if(val < 0) {
neg = TRUE;
val = -val;
}
if(val<=-1 || val>=1)
if(val >= 1)
buf_size = log10(val)+prec+2;
else
buf_size = prec+1;
buf_size = prec ? prec+1 : 2;
if(buf_size > NUMBER_DTOA_SIZE)
buf_size = NUMBER_DTOA_SIZE;
......
......@@ -1204,6 +1204,14 @@ ok(tmp === "101.1", "num(5.5).toString(2) = " + tmp);
tmp = (new Number(3)).toFixed(3);
ok(tmp === "3.000", "num(3).toFixed(3) = " + tmp);
tmp = (new Number(3)).toFixed();
ok(tmp === "3", "Number(3).toFixed() = " + tmp);
tmp = (new Number(0)).toFixed();
ok(tmp === "0", "Number(0).toFixed() = " + tmp);
tmp = (new Number(0)).toFixed(1);
ok(tmp === "0.0", "Number(0).toFixed(1) = " + tmp);
tmp = (new Number(0)).toFixed(2);
ok(tmp === "0.00", "Number(0).toFixed(2) = " + tmp);
tmp = (new Number(1.76)).toFixed(1);
ok(tmp === "1.8", "num(1.76).toFixed(1) = " + tmp);
tmp = (new Number(7.92)).toFixed(5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment