View Single Post
Old 11-21-2002, 02:20 AM   #1 (permalink)
abc123
bloomberg
 
abc123's Avatar
 
Join Date: Jun 2002
Location: bloomberg
Posts: 263
abc123 is on a distinguished road
Send a message via AIM to abc123 Send a message via Yahoo to abc123
Floating away...

has anybody had experience with float calculation ( or just plain decimals ) with javascript...

here is an example:

Code:
<html>
<body>
<input type="text" name="abx" value="800" />
<input type="text" name="abz" value="1.12" />


<script language="javascript">

	function testIt(){
		var f1 = parseFloat(abx.value);
		var f2 = parseFloat(abz.value);
		var re = f1*f2;
		alert("result: " + re);
	}

</script>
<input type="button" onclick="testIt();" value="Click Me" />
</body>
</html>
you would, of course, expect to see "896.0" as the answer..

however if you try it you will get "896.00000000000001" ...

anyone know whats up with this and / or a mathematical work-around?
__________________
-- bloomberg.
abc123 is offline   Reply With Quote