Link to home
Start Free TrialLog in
Avatar of ngobw
ngobw

asked on

Javascript anomaly calculating sum of numbers.

This script boggles me. When the numbers are added, it seems that it doesn't amount to 100, but instead gave a value of 100.000.... 001

Can anyone explain to me why this is so? Thanks!

NOTE: Substitute the plus sign before testing it.
<html>
<head>
<script type='text/javascript'>
function holygrail() {
     sum = 51.4 'plus' 14 'plus' 14 'plus' 11.4 'plus' 7.5 'plus' 1.7;
     alert(sum);
}
</script>
</head>
<body onload='javascript:holygrail();'>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ngobw
ngobw

ASKER

Thanks for the answer.  It's a very interesting find!