JS decimal multiplication

node v8.17.0
version: 2.0.1
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
const Decimal = require("decimal.js-light")
const multiply = (a, b) => (new Decimal(a)).mul(new Decimal(b)).toNumber()
const multiplyFixed = (a, b, fixed = 2) => (new Decimal(a)).mul(new Decimal(b)).toFixed(fixed)
multiply(700, 1.1)
multiplyFixed(700, 1.1)
Loading…

no comments

    sign in to comment