Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Implement unsafe math operators transpilation #1030

Open
piwonskp opened this issue Apr 10, 2023 · 0 comments
Open

Implement unsafe math operators transpilation #1030

piwonskp opened this issue Apr 10, 2023 · 0 comments

Comments

@piwonskp
Copy link
Contributor

In solidity you can use unsafe operators by putting them in an unchecked block:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract UncheckedMath {
    function add(uint x, uint y) external pure returns (uint) {
        // 22291 gas
        // return x + y;

        // 22103 gas
        unchecked {
            return x + y;
        }
    }
}

Cairo 1 got functions implementing unsafe operations in https://github.com/starkware-libs/cairo/blob/9c3cb9633a9ef8595b3ee041a00b37b84d964af7/corelib/src/integer.cairo#L30.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant