firoorg / solidity-BigNumber

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

fixed bitlen calc #18

Open dovgopoly opened 8 hours ago

dovgopoly commented 8 hours ago

Hi, I noticed a potential bug in the _add function when recalculating bitlen. Consider a scenario where the most significant word is already 1 and remains unchanged. In this case, the algorithm incorrectly calculates the result bitlen.

stack.add(
        "0x010000000000000000000000000000000000000000000000000000000000000001",
        "0x01"
);

The result bitlen is 258 but it's expected to be 257.