Created
April 13, 2020 19:44
-
-
Save jensen/b887c46679810f66ab7a1fccd96f2bfe to your computer and use it in GitHub Desktop.
How to use decimal.js library for more precision
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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