{article JavaScript Table of Content}{title} {text} {/article}

Returns a string representation of a number in fixed-point notation, containing fractionDigits digits after the decimal point.

Example 1

<script>
var num = new Number(123);
var fix = num.toFixed();
document.write(fix);
document.write("<br/>");

num = new Number(123.456);
fix = num.toFixed(2);
document.write(fix);
</script>

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

&lt;script&gt;<br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write(&quot;&lt;br/&gt;&quot;);<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(2);<br>
document.write(fix);<br>
&lt;/script&gt;<br>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;<br>
&lt;head&gt;<br>
    &lt;title&gt;title&lt;/title&gt;<br>
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;<br>
    &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;<br>
    &lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;<br>
    &lt;meta name=&quot;robots&quot; content=&quot;index,follow&quot; /&gt;<br>
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles.css&quot; /&gt;<br>
&lt;/head&gt;<br>
<br>
&lt;body&gt;<br>
&lt;script&gt;<br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write(&quot;&lt;br/&gt;&quot;);<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(2);<br>
document.write(fix);<br>
&lt;/script&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;<br>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

Output Esample 1

123
123.46


Example 2

<script>
var num = new Number(123);
var fix = num.toFixed();
document.write(fix);
document.write("<br/>");

num = new Number(123.456);
fix = num.toFixed(6);
document.write(fix);
</script>

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<br>
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;<br>
&lt;head&gt;<br>
    &lt;title&gt;title&lt;/title&gt;<br>
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;<br>
    &lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;<br>
    &lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;<br>
    &lt;meta name=&quot;robots&quot; content=&quot;index,follow&quot; /&gt;<br>
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styles.css&quot; /&gt;<br>
&lt;/head&gt;<br>
<br>
&lt;body&gt;<br>
&lt;script&gt;<br>
var num = new Number(123);<br>
var fix = num.toFixed();<br>
document.write(fix);<br>
document.write(&quot;&lt;br/&gt;&quot;);<br>
<br>
num = new Number(123.456);<br>
fix = num.toFixed(6);<br>
document.write(fix);<br>
&lt;/script&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;<br>

</pre>


<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

Output Example 2

123
123.456000