Skip to content

Instantly share code, notes, and snippets.

@jensen
Created April 13, 2020 19:44
Show Gist options
  • Save jensen/b887c46679810f66ab7a1fccd96f2bfe to your computer and use it in GitHub Desktop.
Save jensen/b887c46679810f66ab7a1fccd96f2bfe to your computer and use it in GitHub Desktop.
How to use decimal.js library for more precision
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>MathJS</title>
<meta name="description" content="MathJS" />
<meta name="author" content="jenskarlsen" />
<script src="./js/decimal.js"></script>
<script>
Decimal.set({ precision: 30 });
document.addEventListener("DOMContentLoaded", () => {
const value = new Decimal(1);
document.getElementById("answer").textContent = value.sin().toString();
});
</script>
</head>
<body>
<h1 id="answer"></h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment