How to use bignumber - 10 common examples

To help you get started, we’ve selected a few bignumber 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 cartesi / arbitration-dlib / utils / mm.js View on Github external
merkel() {
    // console.log(this.memoryMap);
    return this.subMerkel(this.memoryMap, BigNumber(0), 61);
  }
}
github interledgerjs / ilp / src / lib / psk2.js View on Github external
function highLowToBigNumber (highLow) {
  // TODO use a more efficient method to convert this
  const long = Long.fromBits(highLow[1], highLow[0], true)
  return new BigNumber(long.toString(10))
}
github KyberNetwork / smart-contracts / test / liquidityConversionRate.js View on Github external
it("should test getrate for buy=false and qtyInSrcWei = non_0.", async function () {
        let qtyInSrcWei = BigNumber(deltaT).mul(tokenPrecision)
        let expectedResult = priceForDeltaT(feePercent, r, pMin, deltaT, e0).mul(precision).valueOf()
        let result =  await liqConvRatesInst.getRateWithE(token.address,false,qtyInSrcWei,eInFp);
        Helper.assertAbsDiff(result, expectedResult, expectedDiffInPct)
    });
github KyberNetwork / smart-contracts / test / liquidityConversionRate.js View on Github external
it("should test getrate for buy=true and qtyInSrcWei = non_0.", async function () {
        let expectedResult = priceForDeltaE(feePercent, r, pMin, deltaE, e0).mul(precision).valueOf()
        let qtyInSrcWei = BigNumber(deltaE).mul(precision)
        let result =  await liqConvRatesInst.getRateWithE(token.address,true,qtyInSrcWei,eInFp);
        Helper.assertAbsDiff(result, expectedResult, expectedDiffInPct)
    });
github centrehq / centre-tokens / test / TokenTestUtils.js View on Github external
function newBigNumber(value) {
    var hex = new BigNumber(value).toString(16);
    return new BN(hex, 16);
}
github AugurProject / augur.js / test / unit / trading / simulation / simulate-sell.js View on Github external
assertions: function (output) {
      assert.deepEqual(output, {
        sharesFilled: new BigNumber("2", 10),
        settlementFees: ZERO,
        worstCaseFees: ZERO,
        otherSharesDepleted: ZERO,
        sharesDepleted: ZERO,
        tokensDepleted: new BigNumber("0.9", 10),
        shareBalances: [ZERO, new BigNumber("5", 10)],
      });
    },
  });
github AugurProject / augur.js / test / unit / trading / simulation / simulate-fill-bid-order.js View on Github external
assertions: function (output) {
      assert.deepEqual(output, {
        sharesFilled: new BigNumber("2", 10),
        sharesToCover: new BigNumber("1", 10),
        settlementFees: new BigNumber("0.014", 10),
        worstCaseFees: new BigNumber("0.014", 10),
        sharesDepleted: new BigNumber("2", 10),
        tokensDepleted: new BigNumber("0", 10),
        shareBalances: [new BigNumber("3", 10), new BigNumber("0", 10)],
      });
    },
  });
github AugurProject / augur.js / test / unit / trading / simulation / simulate-buy.js View on Github external
assertions: function (output) {
      assert.deepEqual(output, {
        sharesFilled: new BigNumber("2", 10),
        settlementFees: new BigNumber("0.006", 10),
        worstCaseFees: new BigNumber("0.009", 10),
        otherSharesDepleted: new BigNumber("3", 10),
        sharesDepleted: ZERO,
        tokensDepleted: ZERO,
        shareBalances: [ZERO, new BigNumber("2", 10)],
      });
    },
  });
github AugurProject / augur.js / test / unit / trading / simulation / simulate-fill-ask-order.js View on Github external
assertions: function (output) {
      assert.deepEqual(output, {
        sharesFilled: new BigNumber("2", 10),
        sharesToCover: new BigNumber("1", 10),
        settlementFees: new BigNumber("0.006", 10),
        worstCaseFees: new BigNumber("0.006", 10),
        otherSharesDepleted: new BigNumber("2", 10),
        tokensDepleted: ZERO,
        shareBalances: [ZERO, new BigNumber("3", 10)],
      });
    },
  });
github decentraland / eth-connect / src / utils / utils.ts View on Github external
export function getValueOfUnit(_unit: string): BigNumberType {
  let unit = _unit ? _unit.toLowerCase() : 'ether'
  let unitValue = unitMap[unit]
  if (unitValue === undefined) {
    throw new Error(
      "This unit doesn't exists, please use the one of the following units" + JSON.stringify(unitMap, null, 2)
    )
  }
  return new BigNumber(unitValue, 10)
}

bignumber

A pure javascript implementation of BigIntegers and RSA crypto.

Unknown
Latest version published 14 years ago

Package Health Score

39 / 100
Full package analysis

Popular bignumber functions