How to use the number-precision.times function in number-precision

To help you get started, we’ve selected a few number-precision examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bodhiproject / bodhi-ui / src / helpers / utility.js View on Github external
export function decimalToSatoshi(number) {
  if (!number) {
    return number;
  }
  const toStringNumber = Number(number).toFixed(8);
  const splitArr = toStringNumber.split('.');
  const integerPart = splitArr[0];
  const decimalPart = splitArr.length > 1 ? NP.times(Number(`.${splitArr[1]}`), SATOSHI_CONVERSION) : 0;
  const conversionBN = toBN(SATOSHI_CONVERSION);
  return toBN(integerPart).mul(conversionBN).add(toBN(decimalPart)).toString(10);
}

number-precision

Perform addition, subtraction, multiplication and division operations precisely using javascript

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis