반응형
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로 정의된다
반응형
'Blockchain > Crypto Zombies' 카테고리의 다른 글
Making the Zombie Factory - Chapter 5: Structs (0) | 2024.02.06 |
---|---|
Making the Zombie Factory - Chapter 3: State Variables & Integers (0) | 2024.02.06 |
Making the Zombie Factory - Chapter 2: Contracts (0) | 2024.02.06 |
댓글