How to keep decimal rounded to two places? <p>So All of my decimals are rounded to two places. However when I click on "keyboard or mouse" image the decimal place is roughly ten digits long( for example:36.900000000000006). How do I stop this. I've tried using ".toFixed(), and .toPrecision().</p> <p>here is a link to the page... much easier to do this than create a fiddle.</p> <p><a href="http://www.ootpik.info/lauren/ootpik5/gethardware.html" rel="nofollow">http://www.ootpik.info/lauren/ootpik5/gethardware.html</a></p> <p>I've added a fiddle: <a href="http://jsfiddle.net/lolsen7/8uwGH/3/" rel="nofollow">http://jsfiddle.net/lolsen7/8uwGH/3/</a></p> <p>script</p> <pre><code>$(document).ready(function() { $(".part,.extra").mouseover(function() { if(this.className !== 'part selected') { $(this).attr('src', 'images/placeholder/get_hardware/' + this.id + '.png'); } $(this).mouseout(function(){ if(this.className !== 'part selected') { $(this).attr('src', 'images/placeholder/get_hardware/' + this.id + '_grey.png'); } }); }); var list = document.getElementById("list"); var summaryTotal = document.getElementById("summaryTotal"); var touchtotal = 13.89; var minitotal = 19.47; var constant = touchtotal + minitotal; $('#finaltotal').text(constant); //station one var keyboard2 = 59; var mouse2 = 59; var printer = 345; var scale2 = 530; var display = 175; var single = 132; var multi = 260; var scannerTotal = 0; var cash = 100; var storage = 125; var registerTotal = 0; //extras var ipad = 349; var ipadTotal = 0; var mobilePrinter = 570; var mobileTotal = 0; var printer2 = 345; var printer2Total = 0; $(".part").click(function(){ var name = this.id; var liname = this.alt; var total = parseFloat((eval(name) * 1.2) /40); if(this.className != 'part selected') { $(this).attr('src','images/placeholder/get_hardware/' + name + '.png'); if(name !== 'multiBar' &amp;&amp; name !== 'singleBar' &amp;&amp; name !== 'storageDrawer' &amp;&amp; name !== 'cashDrawer' ) { //generate list items var li = document.createElement("li"); li.setAttribute("id",name + "_li"); li.appendChild(document.createTextNode(liname)); list.appendChild(li); //touchscreen and mac mini pricing constant = constant + total; $('#finaltotal').text(constant); } //Scanners if clicked on else if(name == "multiBar" || name == "singleBar"){ $(".tooltip").show(); $("input").change(function(e){ if($(this).attr("checked", "true")) { if(this.value == "one") { // hide and show images based on radio selection $('#singleBar').attr('src','images/placeholder/get_hardware/singleBar.png'); $('#singleBar').show(); $('#singleBar').toggleClass('selected'); $('#multiBar').hide(); //list item if($('#single_li').length &gt; 0) { $('#single_li').remove(); } if($('#multi_li').length &gt; 0) { $('#multi_li').remove(); } li = document.createElement("li"); li.setAttribute("id","single_li"); li.appendChild(document.createTextNode("Single-line Barcode Scanner")); list.appendChild(li); //pricing if(scannerTotal !== 0) { constant = constant - scannerTotal; } scannerTotal = (single * 1.2) /40; constant = constant + scannerTotal; $('#finaltotal').text(constant); }else if(this.value == "two") { //hide and show images based on radio selection $('#multiBar').attr('src','images/placeholder/get_hardware/multiBar.png'); $('#multiBar').show(); $('#singleBar').hide(); //list item if($('#multi_li').length &gt; 0){ $('#multi_li').remove(); } if($('#single_li').length &gt; 0){ $('#single_li').remove(); } li = document.createElement("li"); li.setAttribute("id","multi_li"); li.appendChild(document.createTextNode("Multi-line Barcode Scanner")); list.appendChild(li); if(scannerTotal !== 0){ constant = constant - scannerTotal; } scannerTotal = (multi * 1.2) /40; constant = constant + scannerTotal; $('#finaltotal').text(constant); } } }); } //if register is clicke on else if(name =="storageDrawer" || name == "cashDrawer"){ $('.tooltip2').show(); $('input').change(function(){ if($(this).attr("checked","true")) { if(this.value == "three") { //hide and show images based on radio button selection $('#cashDrawer').attr('src','images/placeholder/get_hardware/cashDrawer.png'); $('#cashDrawer').show(); $("#storageDrawer").hide(); //list items if($('#cash_li').length &gt; 0){ $('#cash_li').remove(); } if($('#storage_li').length &gt; 0){ $('#storage_li').remove(); } li = document.createElement("li"); li.setAttribute('id','cash_li'); li.appendChild(document.createTextNode("Cash Drawer")); list.appendChild(li); //pricing if(registerTotal !== 0){ constant = constant - registerTotal; } registerTotal = (cash * 1.2)/40; constant = constant + registerTotal; $('#finaltotal').text(constant); }else if(this.value == "four") { $('#storageDrawer').attr('src','images/placeholder/get_hardware/storageDrawer.png'); $('#storageDrawer').show(); $('#cashDrawer').hide(); //list items if($('#storage_li').length &gt; 0){ $('#storage_li').remove(); } if($('#cash_li').length &gt; 0){ $('#cash_li').remove(); } li = document.createElement('li'); li.setAttribute('id','storage_li'); li.appendChild(document.createTextNode("Premium Cash Drawer")); list.appendChild(li); //pricing if(registerTotal !== 0){ constant = constant - registerTotal; } registerTotal = (storage * 1.2)/40; constant = constant + registerTotal; $('#finaltotal').text(constant); } } }); } $(this).toggleClass('selected'); } else if (this.className == 'part selected') { $(this).attr('src','images/placeholder/get_hardware/' + name + '_grey.png'); if(name !== 'multiBar' &amp;&amp; name !== 'singleBar' &amp;&amp; name !== 'storageDrawer' &amp;&amp; name !== 'cashDrawer') { constant = constant - total; $('#finaltotal').text(constant); $("#" + name + "_li").remove(); } //Scanners else if(name == 'multiBar' || name == 'singleBar') { //Hides Tooltip when de-selecting item $(".tooltip").hide(); // removes pricing console.log(scannerTotal); constant = constant - scannerTotal; scannerTotal = 0; $('#finaltotal').text(constant); //Removes any List items if($('#multi_li').length &gt; 0) { $('#multi_li').remove(); } if($('#single_li').length &gt; 0) { $('#single_li').remove(); } //Sets Inputs to deselected $("input[name='group1']").attr("checked",false); } //cash drawers || registers else if(name == 'storageDrawer' || name == 'cashDrawer') { $('.tooltip2').hide(); //removes pricing console.log(registerTotal); constant = constant - registerTotal; registerTotal = 0; $('#finaltotal').text(constant); //remove any list items if($('#storage_li').length &gt; 0) { $('#storage_li').remove(); } if($('#cash_li').length &gt; 0) { $('#cash_li').remove(); } //Sets Inputs to deselected $("input[name='group2']").attr("checked",false); } $(this).toggleClass('selected'); } }); $(".numbers-row").append('&lt;div class="inc buttons"&gt;+&lt;/div&gt;&lt;div class="dec buttons"&gt;-&lt;/div&gt;'); $(".buttons").on("click", function() { var $buttons = $(this); var oldValue = $buttons.parent().find("input").val(); if ($buttons.text() == "+") { var newVal = parseFloat(oldValue) + 1; if(newVal &gt; 2 ){ return; } } else { // Don't allow decrementing below zero if (oldValue &gt; 0) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 0; } } $buttons.parent().find("input").val(newVal); if($buttons.parent().attr('class') == 'numbers-row ipad'){ if($('#ipad_mini_extra').length &gt; 0){ $('#list').children('#ipad_mini_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - ipadTotal; console.log(ipadTotal); $('#finaltotal').text(constant); } } if(newVal !== 0){ $('#ipad').attr('src',"images/placeholder/get_hardware/ipad.png"); $('#list').append('&lt;li id="ipad_mini_extra"&gt;' + newVal + ' iPad mini(s) &lt;/li&gt;'); //add pricing if(ipadTotal !== 0){ constant = constant - ipadTotal; } if(newVal == 1){ ipadTotal = (ipad * 1.2) /40; console.log(ipadTotal); constant = constant + ipadTotal; $('#finaltotal').text(constant); } if(newVal == 2){ ipadTotal = ((ipad * 2) * 1.2)/40; console.log(ipadTotal) constant =constant + ipadTotal; $('#finaltotal').text(constant); } } else{ $('#ipad').attr('src',"images/placeholder/get_hardware/ipad_grey.png"); } } if($buttons.parent().attr('class') == 'numbers-row mobile') { if($('#mobile_extra').length &gt; 0) { $('#list').children('#mobile_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - mobileTotal; console.log(mobileTotal); $('#finaltotal').text(constant); } } if(newVal !== 0) { $('#mobilePrinter').attr('src',"images/placeholder/get_hardware/mobilePrinter.png"); $('#list').append('&lt;li id="mobile_extra"&gt;' + newVal + ' Mobile Printer(s) &lt;/li&gt;'); //add pricing if(mobileTotal !== 0){ constant = constant - mobileTotal; } if(newVal == 1){ mobileTotal = (mobilePrinter * 1.2) /40; console.log(mobileTotal); constant = constant + mobileTotal; $('#finaltotal').text(constant); } if(newVal == 2){ mobileTotal = ((mobilePrinter * 2) * 1.2)/40; console.log(mobileTotal) constant =constant + mobileTotal; $('#finaltotal').text(constant); } } else { $('#mobilePrinter').attr('src',"images/placeholder/get_hardware/mobilePrinter_grey.png"); } } if($buttons.parent().attr('class') == 'numbers-row printer2') { if($('#printer2_extra').length &gt; 0) { $('#list').children('#printer2_extra').remove(); //remove pricing if(newVal == 0){ constant = constant - printer2Total; console.log(printer2Total); $('#finaltotal').text(constant); } } if(newVal !== 0) { $('#printer2').attr('src',"images/placeholder/get_hardware/printer2.png"); $('#list').append('&lt;li id="printer2_extra"&gt; ' + newVal + ' Kitchen/Bar/Expo Printer(s) &lt;/li&gt;'); //add pricing if(printer2Total !== 0){ constant = constant - printer2Total; } if(newVal == 1){ printer2Total = (printer2 * 1.2) /40; console.log(printer2Total); constant = constant + printer2Total; $('#finaltotal').text(constant); } if(newVal == 2){ printer2Total = ((printer2 * 2) * 1.2)/40; console.log(printer2Total) constant =constant + printer2Total; $('#finaltotal').text(constant); } } else { $('#printer2').attr('src',"images/placeholder/get_hardware/printer2_grey.png"); } } }); }); </code></pre>