본문 바로가기
Blockchain/Crypto Zombies

Making the Zombie Factory - Chapter 4: Math Operations

by GrayChoi 2024. 2. 6.
반응형

 

Chapter 4: Math Operations

 

Solidity's operations are the same as in most programming languages

Addition: x + y

Subtraction: x - y

Multiplication: x * y

Division: x / y

Modulus / remainder: x % y

 

exponential operator

uint x = 5 ** 2; // equal to 5^2 = 25

 

Put it to the test

pragma solidity >=0.5.0 <0.6.0;

contract ZombieFactory {

    uint dnaDigits = 16;
    uint dnaModulus = 10 ** dnaDigits;

}

 

 


 

 

그 외 comparisons, bit operators, shift operators, equality 등이 있다

0 ** 0 은 EVM에 의해 1로 정의된다

반응형

댓글