Skip to content

Instantly share code, notes, and snippets.

@leachdaniel
Created December 30, 2017 21:22
Show Gist options
  • Save leachdaniel/7e43fff3b91969ec4d372c56f2b808c8 to your computer and use it in GitHub Desktop.
Save leachdaniel/7e43fff3b91969ec4d372c56f2b808c8 to your computer and use it in GitHub Desktop.
JavaScript Rounding
if ((14.28*9 != 128.52) || (66.66*5 != 333.3) || (21.17*6 != 127.02)) {
document.write("<b>Rounding Errors Detected:</b><BR><BR>");}
else {document.write("<b>No Rounding Errors Detected:</b><BR><BR>"); }
document.write("14.28 x 9 should be <b>128.52</b>;<br><small>your browser's answer = </small><b>" + (14.28*9)+"</b><br><br>");
document.write("66.66 x 5 should be <b>333.3</b>;<br><small>your browser's answer = </small><b>" + (66.66 * 5)+"</b><br><br>");
document.write("21.17 x 6 should be <b>127.02</b>;<br><small>your browser's answer = </small><b>" + (21.17*6)+"</b><br><br>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment