Get started with decimal.js CDN

MIT licensed

Decimal.js: High-precision, flexible decimal arithmetic library.

Tags:
  • arbitrary
  • precision
  • arithmetic
  • big
  • number
  • decimal
  • float
  • biginteger
  • bigdecimal
  • bignumber
  • bigint
  • bignum

Stable version

Copied!

How to start using decimal.js CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with decimal.js CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/decimal.js/10.4.3/decimal.min.js"></script>
</head>
<body>
    <script>
        // Create Decimal instances
        const decimal1 = new Decimal(10.5);
        const decimal2 = new Decimal(5.25);

        // Perform arithmetic operations
        const sum = decimal1.add(decimal2);
        const difference = decimal1.subtract(decimal2);
        const product = decimal1.multiply(decimal2);
        const quotient = decimal1.dividedBy(decimal2);

        // Display results
        console.log("Sum:", sum.toNumber());
        console.log("Difference:", difference.toNumber());
        console.log("Product:", product.toNumber());
        console.log("Quotient:", quotient.toNumber());
    </script>
</body>
</html>
Copied!
Copied!
Copied!

All versions