Exemple #1
0
        public void OverflowCap()
        {
            // Cap a 256-bit integer (32 bytes)
            BigInteger bigInt = EVMDefinitions.UINT256_MAX_VALUE + 2;

            bigInt = bigInt.CapOverflow(); // default value accounts for this.
            Assert.Equal(1, bigInt);

            // Cap a 32-bit integer (4 bytes)
            bigInt = (BigInteger)uint.MaxValue + 7;
            bigInt = bigInt.CapOverflow(4); // 32-bits = 4 bytes
            Assert.Equal(6, bigInt);
        }