margelo / react-native-bignumber

🔢 The fastest Big Number library for React Native
https://margelo.io
MIT License
342 stars 12 forks source link

.toString('hex') and .toString(16) not returning correct hexadecimal representation #60

Closed nnnoel closed 12 months ago

nnnoel commented 1 year ago

When using the .toString('hex') and .toString(16) methods on a BN object, the returned value doesn't seem to represent the correct hexadecimal format of the number. Instead, it's simply returning the decimal value as a string.

Code Sample

With bn.js:

console.log(
  "BN result",
  new BN(100).toString("hex"),
  new BN(100).toString(16),
);
// Expected LOG:  BN result 64 64

With react-native-bignumber:

console.log(
  "BN result",
  new BN(100).toString("hex"),
  new BN(100).toString(16),
);
// Actual LOG:  BN result 100 100

Env info:

    "react-native": "0.71.7",
    "react-native-bignumber": "^0.2.1",
    "bn.js": "^5.2.1",