Created
January 26, 2022 13:33
-
-
Save raj-pranav/60184468833969964fae355dab9369b7 to your computer and use it in GitHub Desktop.
Operators in Solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract comparison_operator { | |
uint x = 10; | |
uint y = 12; | |
int z = 10; | |
// Less than | |
bool res = x < y; // res = true | |
// Less than or equal to | |
bool res1 = x <= y; // res1 = true | |
bool s_res1 = x <= 10; // s_res1 = true | |
// Greater than | |
bool res2 = x > y; // res2 = false | |
// Greater than or equal to | |
bool res3 = x >= y; // res3 = false | |
bool s_res3 = x >= 10; // s_res3 = true | |
// Is equal to (eqality) | |
bool res4 = x == y; // res4 = false | |
// Not equal to | |
bool res5 = x != y; // res5 = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment