andyperlitch / jsbn

The jsbn library is a fast, portable implementation of large-number math in pure JavaScript, enabling public-key crypto and other applications on desktop and mobile browsers.
Other
167 stars 41 forks source link

How to divide? #31

Open xeroxstar opened 5 years ago

xeroxstar commented 5 years ago

Cant find docs how to use this module, i need to divide a number but i am getting an error:

const BigInt = require('jsbn').BigInteger
let num = new BigInt('8888888888888888');
console.log(num.divide(2));

C:\debug\node_modules\jsbn\index.js:357
      var pm = m.abs();
                 ^

TypeError: m.abs is not a function
    at BigInteger.bnpDivRemTo [as divRemTo] (C:\debug\node_modules\jsbn\index.js:357:18)
    at BigInteger.bnDivide [as divide] (C:\debug\node_modules\jsbn\index.js:861:48)
    at Timeout.setTimeout [as _onTimeout] (C:\debug\api\subscription\subscription.service.js:20:27)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

I am not sure if this is a bug or i am doing something wrong.