Hi folks. I’m going a little crazy here. I’m running into a javascript multiplication issue. Here’s the sample code (entire page); it just calculates a floating point multiplication problem and prints it to the screen:
[code]
<!DOCTYPE html PUBLIC “-//W3C//DTD
XHTML 1.1//EN” “http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.
dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Language” content=”en-gb” />
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<meta name=”robots” content=”index, follow” />
<title>JS Test</title>
<script type=”text/javascript”>
//<![CDATA[
function jstest(){
document.getElementById(“testresult”).appendChild(
document.createTextNode(“.4 * .4 = “+(.4 * .4))
);
}
//]]>
</script>
</head>
<body onload=”jstest()”>
<p id=”testresult”></p>
</body>
</html>
Everywhere I’ve tested this (IE, FF, Safari), it gives a page with the same result:
[B].4 * .4 = 0.16000000000000003
Where the heck is that .00000000000000003 coming from? Anyone seen this before?