firoorg / solidity-BigNumber

Full BigNumber library implementation for Solidity.
MIT License
92 stars 22 forks source link

Converting BigNumber into int256 #12

Open ediskandarov opened 1 year ago

ediskandarov commented 1 year ago

Hi there,

Assuming, the code can inspect big number, and if ensured it fits into int256 - how to covert it?

I didn't find any example.

jdbertron commented 1 year ago

You can just use abi.encodePacked(bn);

I added this to my version of the library for debugging purposes, but it's not necessay.

function toBytes(BigNumber memory n) public pure returns(bytes memory r){ return n.val; }

riordant commented 1 year ago

Hi there,

Assuming, the code can inspect big number, and if ensured it fits into int256 - how to covert it?

I didn't find any example.

Hi, the conversion functions are indeed lacking. I will take a look at adding more, as it seems there is some demand for this.