laylo

09-10-2011, 11:44 PM

var n = 123456.789;

n.toFixed(0);

just starting out JavaScript. So i type the above code in firebug. it returns this result:- "123457"

As for as i know, toFixed() converts a number to a string with a specified number of digits after the decimal point.

If i have specified 0, which i'm assuming it means 0 digits after the decimal point, why does the 7 appear and the 6 is taken out.

really fustrating and can't seem to get my head over it.

n.toFixed(0);

just starting out JavaScript. So i type the above code in firebug. it returns this result:- "123457"

As for as i know, toFixed() converts a number to a string with a specified number of digits after the decimal point.

If i have specified 0, which i'm assuming it means 0 digits after the decimal point, why does the 7 appear and the 6 is taken out.

really fustrating and can't seem to get my head over it.