I'm using the VERY simple bit of code below to add together two ints, but insted of the right answer 20.8 i get 20.799999999999997.

I have no idea whats happening here!! can any give me a hand with this one?

Mark www.freeloader.com

<title>Number Bug</title>

<script language="JavaScript">

//Just adding two floats together!!!!
var tmp = 10.6+10.2;
document.write("Adding 10.6 & 10.2 together produces; "+tmp+"<br>");

//Using the function 'nasty' to fix the error
tmp = nasty(tmp);
document.write("Using a nasty function to fix the error produces; "+tmp+"<br>");


function nasty(fixedInt){
fixedInt = Math.round(fixedInt * 10);
return fixedInt /= 10;

// -->