BasicMath

Description:

Smart contract deployed on Ethereum.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

contract BasicMath {
    uint256 constant MAX_INT = type(uint256).max;

    function adder(uint256 _a, uint256 _b) external pure returns (uint256 sum, bool error) {
        if (_b > MAX_INT - _a) {
            return (0, true); // Overflow occurred
        }
        return (_a + _b, false);
    }

    function subtractor(uint256 _a, uint256 _b) external pure returns (uint256 difference, bool error) {
        if (_b > _a) {
            return (0, true); // Underflow occurred
        }
        return (_a - _b, false);
    }
}

Tags:
addr:0x67b09a175aab8ed9c9b5f9d3ba610c80b6ed62cf|verified:true|block:23503109|tx:0x0952b8dda80346a16811e9aa45407038d1905603c2ec441c81d49d3bdc85dd75|first_check:1759572174

Submitted on: 2025-10-04 12:02:54

Comments

Log in to comment.

No comments yet.